he i made a simple reservation system please help me with code on how i can cancel a reservation

import java.util.Scanner;
import java.util.Date;

public class reservation {

    // Create an array of 12 seats, 6 window and 6 aisle.
    private static int[] seats = new int[12];

    public static void main(String args[]) {
        System.out.println("Welcome to the saintb's reservation system!");
        System.out.println();
        

        // Lets start by setting all seats equal to 0 ( Empty)
        for (int i = 0; i < 12; i++) {
            seats[i] = 0;
        }

        // Setup our scanner and default the choice to firstclass.
        Scanner s = new Scanner(System.in);
        int choice = 1;

        // Ask user for a window or an aisle seat and store their choice.
        System.out.print("Please enter 1 for firstclass, 2 for economy, or 0 to exit: ");
        choice = s.nextInt();


        // While their choice is not the one for exit, execute our booking.
        while (choice != 0) {
            int seatnumber = 0;


            // If they chose a Firstclass seat, attempt to book it.
            if (choice == 1) {
                seatnumber = bookFirstclass();


                // No first class seats available, try booking an Economy seat for them instead.
                if (seatnumber == -1) {
                    seatnumber = bookEconomy();
                
                    if (seatnumber != -1) {
                        System.out.println("Sorry, we were not able to book a firstclass seat. But do have an economy seat.");
                        printBoardingPass(seatnumber);
                    }
                }
                else {
                    // Booking a First class seat was successful.
                    System.out.println("You are in luck, we have a First class seat available!");
                    printBoardingPass(seatnumber);
                }
            }
            else if (choice == 2) {

                // If they chose booking an economy, check to see if it is available.
                seatnumber = bookEconomy();
            
                // If not available, see if we have firstclass seats available.
                if (seatnumber == -1) {
                    seatnumber = bookFirstclass();

                    if (seatnumber != -1) {
                        System.out.println("Sorry, we were not able to book an economy seat. But do have a firstclass seat.");
                        printBoardingPass(seatnumber);
                    }
                }
                else {
                    // Booking an eonomy seat was successful.
                    System.out.println("You are in luck, we have an economy seat available!");
                    printBoardingPass(seatnumber);
                }
            }
            else {
                // Print an error message if they did not choose 1, 2, or 0 for their choice.
                System.out.println("Invalid choice made. Please try again!");
                choice = 0;
            }


            // No window or economy seats were available.
            if (seatnumber == -1) {
                System.out.println("We are sorry, there are no economy or firstclass seats available.");
                System.out.println();
            }


            // Reprompt for a choice
            System.out.print("Please enter 1 for first class, 2 for economy, or 0 to exit: ");
            choice = s.nextInt();
        }

            
    }


    // This function checks for window seats and returns seat number or -1 if full.
    private static int bookFirstclass() {
        for (int i = 0; i < 6; i++) {
            if (seats[i] == 0) {
                seats[i] = 1;
                return i + 1;
            }
        }
        return -1;
    }


    // This function checks to see if aisle seats were available, -1 if full.
    private static int bookEconomy() {
        for (int i = 6; i < 12; i++) {
            if (seats[i] == 0) {
                seats[i] = 1;
                return i + 1;
            }
        }
        return -1;

    }


    // This simply prints out a nice little boarding pass message with their seat number and date of issue.
    private static void printBoardingPass(int seatnumber) {
        Date timenow = new Date();
        System.out.println();
        System.out.println("Date: " + timenow.toString());
        System.out.println("Boarding pass for seat number: " + seatnumber);
        System.out.println("This ticket is non-refundable and non-transferable.");
        System.out.println("Please be curteous, do not smoke. Enjoy your trip.");
        System.out.println();
    }
}

Not urgent. Ask again nicely in a few years and we may have time to help you.

sorry for that what i meant is i urgently need help with code about cancelling a reservation its is part of homework and i have only managed to do the reservation part.please anyone help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.