Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am making a AirlineReservations system some of it works but I dont know how to

ID: 3768372 • Letter: I

Question

I am making a AirlineReservations system some of it works but I dont know how to make the seating system to work can someone please help me here is the description that my professor wants and the programs that i did

Present the user with the following menu

AIRLINE RESERVATION SYSTEM MAIN MENU

1)      Book a reservation

2)      Cancel a reservation

3)      Print Current Seating Chart

4)      Exit System

If the user Chooses “1” Present the user with the following menu

SEATING CHOICE MENU

1)       Choose Ticket Type (First Class, Business Class, Economy Class)

2)      Exit to Main Menu

If the user Chooses “1” Present the user with the following menu

            CLASS CHOICE MENU

1)      First Class

2)       Business Class

3)       Economy Class

4)      Back to Previous Menu

NOTE: Here once the user chooses the type of ticket then let your program print the current seating chart and ask the user for the desired seat. NOTE: “X” means the seat is already taken. “*” means the seat is available.

Example:

A

B

C

D

E

F

Row 1

X

X

*

X

*

*

Row 2

*

*

*

*

*

*

Row 3

*

*

*

*

*

*

Row 4

*

*

*

*

*

*

Row 5

*

*

*

X

*

*

Row 6

*

*

*

*

*

*

Row 7

*

*

*

*

*

*

Row 8

*

*

*

*

*

*

Row 9

X

*

X

*

*

*

Row 10

*

*

*

*

*

*

Row 11

*

*

*

*

*

*

Row 12

*

*

*

*

*

*

Row 13

*

*

*

*

*

*

After the seating chart has been displayed prompt for the desired row number based on the class (Recall: Rows 1 and 2 are First Class, Rows 3-7 are Business class and rows 8-13 are Economy class).

Example (Let’s say the user has chosen First class then display the following):

Enter row choice (Rows 1 – 2 | Enter “0” – to return to previous menu):

If the user enters an invalid choice then present an error message “Invalid Choice! Please Try again…) and then redisplay the row choice menu.

If the user enters a valid row choice then display the following:

Enter Seat choice (Seats “A” – “F” | Enter “0” – to return to previous menu):

NOTE: IF the seat is not available then issue the following error message:

Example:

SEAT “1A”IS NOT AVAILABLE! PLEASE MAKE ANOTHER SELECTION.

Then re-present the row choice menu

Once the user makes a valid choice issue a confirmation message:

Example:

YOU’VE BEEN ASSIGNED SEAT 2B!

Quietly update the seating chart.

Methods to create

Create the following methods in a separate file in solving this problem:

Create a class called “MenuSystem.java” for “presentMenu” method.

Create a class called “SeatingSystem.java” for the rest of the methods.

Create a class called “AirReservation.java” for the main program.

public static int presentMenu(String menuID);

Description: This method will handle ALL menu situations. Each necessary menu will have a ID associated with it menuID). Each menu will always return an integer as a choice. Whenever we desire a particular menu to be displayed we will just call this method and send in the ID of the menu we want displayed. (NOTE: Use the following IDs for the menus: “main” – Main menu, “sc-choice” – Seating Choice menu, “cc-menu” – Class choice menu, “rc-menu” – Row choice menu, “seat-menu” – Seat choice menu (A, B, C, D, E or F). Note if the user enters an invalid response the system should issue an appropriate error message.

public static boolean seatAvailable(char [][] seatingChart, String seatCode);

Description: This method will return a Boolean (true/false) result. Given a seat code such as “2C” for example it will check to see if the seat is available.

public static int seatAssign(char [][] seatingChart, String seatCode);

Description: This method will update the seating chart with a seat assignment. If the seat is successfully assigned it will return a “1” if it is unsuccessful it will return a “-1” (e.g. seat already assigned)

public static int seatUnassign(char [][] seatingChart, String seatCode);

Description: This method will update the seating chart by relinquishing or un-assigning a seat. . If the seat is successfully unassigned it will return a “1” if it is unsuccessful it will return a “-1” (e.g. seat was never occupied to begin with)

public static void displaySeatingchart(char [][] seatingChart);

Description: This method will simply display the current seating chart.

Example (No need to display borders):

A

B

C

D

E

F

Row 1

X

X

*

X

*

*

Row 2

*

*

*

*

*

*

Row 3

*

*

*

*

*

*

Row 4

*

*

*

*

*

*

Row 5

*

*

*

X

*

*

Row 6

*

*

*

*

*

*

Row 7

*

*

*

*

*

*

Row 8

*

*

*

*

*

*

Row 9

X

*

X

*

*

*

Row 10

*

*

*

*

*

*

Row 11

*

*

*

*

*

*

Row 12

*

*

*

*

*

*

Row 13

*

*

*

*

*

*

main programpublic class AirReservation {

   public static void main(String[] args)
   {
       char[][] airplane = new char[13][6];
      
       MenuSystem.displayMenu(" ");


       char choice=MenuSystem.presentMenuResponse();

       MenuSystem.presentMenuResponse(choice, airplane);


       //String menuId=MenuSystem.presentMenuResponse2(menuId, choice);

       //int choice1 = MenuSystem.presentMenuResponse2(menuId, scChoicemenu);
       int scChoicemenu=MenuSystem.presentMenuResponse2("scChoicemenu", 0);
       MenuSystem.displayMenu(" ");
       if (scChoicemenu == 1){
           MenuSystem.displayTicketTypeMenu();
           MenuSystem.presentMenuResponse();
       }
  
       int rwChoicemenu=MenuSystem.presentMenuResponse3("rwChoicemenu",0);
      

       if (rwChoicemenu == 1)
           MenuSystem.displayTicketTypeMenu();
           MenuSystem.presentMenuResponse();
  
      
  

       int cwChoicemenu=MenuSystem.presentMenuResponse4("cwChoicemenu",1);
       {

       if (cwChoicemenu==1)
       {
           MenuSystem.displayTicketTypeMenu();
           MenuSystem.presentMenuResponse();
       }
      

       //for(int x =0; x < airplane.length; x++)
//{
    // for (char y=0; y < airplane[x].length; x++)
        // airplane[x][y] = '*';
      
      
  
       
           
        }
   }
}
           
      
      

import java.awt.Choice;
import java.util.Scanner;

public class MenuSystem
{ // This method will let the main menu to appear with choices
   public static void displayMenu(String MainMenu)
   {
       System.out.println("Please choose the following choices: ");
       System.out.println("1. Book a reservation ");
       System.out.println("2. Cancel a reservation ");
       System.out.println("3. Print Current Seating Chart ");
       System.out.println("Press 0 to Exit System " );
   }
   public static char presentMenuResponse()
{
           Scanner scan = new Scanner(System.in);
          
           System.out.println(" Enter your choosing: ");
          
           String Tt = scan.nextLine();
          
char choosing = Tt.charAt(0);
return choosing;
          

       }
   // this will let the user decide if they want to reserve a seat or cancel a seat
  
   public static void presentMenuResponse(char MenuResponse, char [][] SeatingChoice)
   {
       Scanner scan = new Scanner(System.in);
       String reserve;
       switch (MenuResponse)
       {
       case '1':
             
           //System.out.println("Do you want to reserve a seat y/n");
           //reserve = scan.nextLine();
           // System.out.println("Please enter 'Y' for yes and 'N' for no");
             
           displayTicketTypeMenu();

           break;
             
       case '2': System.out.println(" Do you want to cancel a reservation");
       scan.nextLine();
       break;
       case '3': System.out.println("Print out the seating chart: ");
       break;
       case '4': System.out.println("Press 1 to Exit the System and back to the MainMenu");
       System.exit(1);
       break;
         
       default:
           System.out.println(" This is invalid response ");
             
       }
   }
       // this method will display the seating choice menu
   public static int presentMenuResponse2(String menuId, int scChoicemenu)         
   {
       Scanner scan = new Scanner(System.in);
         
       if (menuId.equalsIgnoreCase("scChoicemenu"))
       {
       System.out.println("Seating Choice Menu");
         
         
       System.out.println("1) Choose Ticket Type (First Class, Business Class, Economy Class)");
         
         
       System.out.println("2) Exit to Main Menu");
  
     
  
   System.out.println("Choose a option to proceed to the next section or '2' to go back to the MainMenu");
           scChoicemenu = scan.nextInt();
       }
         
       int sChoice = scChoicemenu;
       return sChoice;
       }
   // this method will return the seating choice menu
   public static int getcChoice(int scChoice)
   { Scanner scan = new Scanner(System.in);
       System.out.println("Enter your choice");
       String s = scan.nextLine();
   int Classchoice = s.charAt(0);
   return scChoice;
   }     
   // this method will display the ticket type menu
       public static void displayTicketTypeMenu()
         
       {
             
               System.out.println("Please choose a ticket type");
       System.out.println("1. Firstclass");
       System.out.println("2. Businessclass");
       System.out.println("3. Economyclass");
       System.out.println("0. Exit to the MainMenu");
       System.out.println();

       }
         
       public static char getCchoice(char ClassChoice)
       { Scanner scan = new Scanner(System.in);
           System.out.println("Enter your Class choice");
           String c = scan.nextLine();
       char Classchoice = c.charAt(0);
       return Classchoice;
         

       } // This method and switch statement will let the user to pick what row they want to assigned to e.g if they
       //want to be seated in first class they will type a 1.
       public static int presentMenuResponse3(String menuId, int rwChoicemenu)         
           {
               Scanner scan = new Scanner(System.in);
               if(menuId.equalsIgnoreCase("rwChoice"));
                 
               System.out.println("Row Choice Menu");

               System.out.println("1)(For first class type numbers type '1-2'");
              
               System.out.println("2)(For Business class type '3-7'");

           System.out.println("3)(For Economy class type '8-13' ");
                 
             
                 
               System.out.println("Choose a option to proceed to the column choice");
               rwChoicemenu= scan.nextInt();
             
             
           int rwChoice= rwChoicemenu;

           return rwChoice;}
           public static char getrcchoice(char ClassChoice)
           { Scanner scan = new Scanner(System.in);
               System.out.println("Enter your Class choice");
               String c = scan.nextLine();
           char Classchoice = c.charAt(0);
           return Classchoice;
             
          
           }// This method and switch statement will let the user what column of seats they want to be assigned to
               public static int presentMenuResponse4(String menuId, int cwChoicemenu)         
               {   
                   Scanner scan = new Scanner(System.in);
                   System.out.println("Seat Choice Menu");
                     
                   if(menuId.equalsIgnoreCase("cwChoicemenu==1"));
                   {
                     
                   System.out.println("1)(For first class type letters 'A' , 'B' ");}
                     
                     
                   System.out.println("2)(For Business Class type letter 'c','d' ");
                     
                     
               System.out.println("3)(For Economy class type , 'E' , 'F' ");
              
                     
              
                       System.out.println("Choose a option to proceed || Pres '0' to exit to main menu ");
cwChoicemenu = scan.nextInt();
              
                   int cwChoice=cwChoicemenu;

                   return cwChoice;

           }
              
               }

public class SeatingSystem {
   public static int seatingChart;//This public variable will make the all switch statement to work
   //This method will be a boolean statement to make what seats are available and return if it is
   //false or true.
   public static boolean seatAvailable(char [][] seatingchart, int rwChoice, int cwChoice, int seChoice ,boolean x)
   {      
       switch(seatingChart)
       {

       case '1':
           System.out.println(seatingChart);
           System.out.println("rwChoice-1");
           break;
       case '2': System.out.println(seatingChart);
       System.out.println("cwChoice-1");
       break;
       case '3': System.out.println(seatingChart);
       System.out.println("seChoice!=-1");
       break;

       case'4': if(x)   return true;
       break;
       }
       otherwise:
           return false;
   }

   // This method will be an integer and a char statement with a nested
   //if else statment to assign the seat
   public static int seatAssign(char[][] seatingChart, int rwChoice, int seChoice, int seatingChart2)
   {
      

       switch(rwChoice)
       {

       case '1':
           if(seatingChart[rwChoice-1][(seChoice-1)]== '*' && rwChoice !=-1 && seChoice!=-1);
           else seatingChart[(rwChoice-1)][(seChoice-1)]='x';
           break;
       case '2':
           if(seatingChart[rwChoice-1][(seChoice-1)]== 'x' && rwChoice !=-1 && seChoice!=-1);
           else seatingChart[(rwChoice-1)][(seChoice-1)] ='*';
           break;
       default:
           return 1;
       }
       otherwise:
       {
           return -1;
       }
   }
   public static int seatUnAssign(char[][] seatingChart, int rwChoice, int seChoice)
   {
      

       switch(seChoice)
       {

       case '1':
           if(seatingChart[rwChoice-1][(seChoice-1)]== '*' && rwChoice !=-1 && seChoice!=-1);
           else seatingChart[(rwChoice-1)][(seChoice-1)]='*';
           break;

       case '2':
           if(seatingChart[rwChoice-1][(seChoice-1)]== '*' && rwChoice !=-1 && seChoice!=0);
           else seatingChart[(rwChoice-1)][(seChoice-1)] ='*';
           break;
       default:
           return 0;
       }
       otherwise:
           return 1;
   }
   // this method will display and print the seating chart
   public static void displaySeatingchart(char[][]seatingChart)
   {
       char x=0;
       char y=0;
       int count=0;
       System.out.println(" A B C D E F");

       for(x=0; x <seatingChart.length-1; x++)
           if(x <=13)
           {
               System.out.println("rwChoice" + (x+1)+ " ");
           }
           else
               System.out.println("colChoice" + (x+y)+ " ");

       for(y=0; y <seatingChart[x].length; y++)
       {
           System.out.println(seatingChart[x][y] + " ");
       }
       if(y+1% 6 ==0)
       {   
           System.out.println(seatingChart[x][y] + " ");
       }

       else
       {
           System.out.println("* ------Available");
       }
       {
           System.out.println("x ------occupied");
           System.out.println(" ");
       }

       count++;


   }
}


  

A

B

C

D

E

F

Row 1

X

X

*

X

*

*

Row 2

*

*

*

*

*

*

Row 3

*

*

*

*

*

*

Row 4

*

*

*

*

*

*

Row 5

*

*

*

X

*

*

Row 6

*

*

*

*

*

*

Row 7

*

*

*

*

*

*

Row 8

*

*

*

*

*

*

Row 9

X

*

X

*

*

*

Row 10

*

*

*

*

*

*

Row 11

*

*

*

*

*

*

Row 12

*

*

*

*

*

*

Row 13

*

*

*

*

*

*

Explanation / Answer

// AirReservation.java

public class AirReservation {
   public static void main(String[] args) {
   char[][] airplane = new char[13][6];
   MenuSystem.displayMenu(" ");

   char choice=MenuSystem.presentMenuResponse();

//String menuId=MenuSystem.presentMenuResponse2(menuId, choice);
//int choice1 = MenuSystem.presentMenuResponse2(menuId, scChoicemenu);
int scChoicemenu=MenuSystem.presentMenuResponse2("scChoicemenu", 0);
if (scChoicemenu == 1){
MenuSystem.displayTicketTypeMenu();
MenuSystem.presentMenuResponse();
}
  
int rwChoicemenu=MenuSystem.presentMenuResponse3("rwChoicemenu",0);
  
if (rwChoicemenu == 1)
MenuSystem.presentMenuResponse();
  
  
  
String cwChoicemenu=MenuSystem.presentMenuResponse4("cwChoicemenu","1");
{
if (cwChoicemenu.equals("1"))
{
MenuSystem.displayTicketTypeMenu();
MenuSystem.presentMenuResponse();
}
  
//for(int x =0; x < airplane.length; x++)
//{
// for (char y=0; y < airplane[x].length; x++)
// airplane[x][y] = '*';
  
  
  


}
}
}

// MenuSystem.java

import java.awt.Choice;
import java.util.Scanner;
public class MenuSystem
{ // This method will let the main menu to appear with choices
public static void displayMenu(String MainMenu)
{
System.out.println("Please choose the following choices: ");
System.out.println("1. Book a reservation ");
System.out.println("2. Cancel a reservation ");
System.out.println("3. Print Current Seating Chart ");
System.out.println("Press 0 to Exit System " );
}
public static char presentMenuResponse()
{
Scanner scan = new Scanner(System.in);
  
System.out.println(" Enter your choosing: ");
  
String Tt = scan.nextLine();
  
char choosing = Tt.charAt(0);
return choosing;
  
}
// this will let the user decide if they want to reserve a seat or cancel a seat
  
public static void presentMenuResponse(char MenuResponse, char [][] SeatingChoice)
{
Scanner scan = new Scanner(System.in);
String reserve;
switch (MenuResponse)
{
case '1':

//System.out.println("Do you want to reserve a seat y/n");
//reserve = scan.nextLine();
// System.out.println("Please enter 'Y' for yes and 'N' for no");

displayTicketTypeMenu();
break;

case '2': System.out.println(" Do you want to cancel a reservation");
scan.nextLine();
break;
case '3': System.out.println("Print out the seating chart: ");
break;
case '4': System.out.println("Press 1 to Exit the System and back to the MainMenu");
System.exit(1);
break;

default:
System.out.println(" This is invalid response ");

}
}
// this method will display the seating choice menu
public static int presentMenuResponse2(String menuId, int scChoicemenu)   
{
Scanner scan = new Scanner(System.in);

if (menuId.equalsIgnoreCase("scChoicemenu"))
{
System.out.println("Seating Choice Menu");


System.out.println("1) Choose Ticket Type (First Class, Business Class, Economy Class)");


System.out.println("2) Exit to Main Menu");
  

  
System.out.println("Choose a option to proceed to the next section or '2' to go back to the MainMenu");
scChoicemenu = scan.nextInt();
}

int sChoice = scChoicemenu;
return sChoice;
}
// this method will return the seating choice menu
public static int getcChoice(int scChoice)
{ Scanner scan = new Scanner(System.in);
System.out.println("Enter your choice");
String s = scan.nextLine();
int Classchoice = s.charAt(0);
return scChoice;
}   
// this method will display the ticket type menu
public static void displayTicketTypeMenu()

{

System.out.println("Please choose a ticket type");
System.out.println("1. Firstclass");
System.out.println("2. Businessclass");
System.out.println("3. Economyclass");
System.out.println("0. Exit to the MainMenu");
System.out.println();

}

public static char getCchoice(char ClassChoice)
{ Scanner scan = new Scanner(System.in);
System.out.println("Enter your Class choice");
String c = scan.nextLine();
char Classchoice = c.charAt(0);
return Classchoice;

} // This method and switch statement will let the user to pick what row they want to assigned to e.g if they
//want to be seated in first class they will type a 1.
public static int presentMenuResponse3(String menuId, int rwChoicemenu)   
{
Scanner scan = new Scanner(System.in);
if(menuId.equalsIgnoreCase("rwChoice"));

System.out.println("Row Choice Menu");
System.out.println("1)(For first class type numbers type '1-2'");
  
System.out.println("2)(For Business class type '3-7'");
System.out.println("3)(For Economy class type '8-13' ");



System.out.println("Choose a option to proceed to the column choice");
rwChoicemenu= scan.nextInt();


int rwChoice= rwChoicemenu;
return rwChoice;}
public static char getrcchoice(char ClassChoice)
{ Scanner scan = new Scanner(System.in);
System.out.println("Enter your Class choice");
String c = scan.nextLine();
char Classchoice = c.charAt(0);
return Classchoice;

  
}// This method and switch statement will let the user what column of seats they want to be assigned to
public static String presentMenuResponse4(String menuId, String cwChoicemenu)   
{   
Scanner scan = new Scanner(System.in);
System.out.println("Seat Choice Menu");

if(menuId.equalsIgnoreCase("cwChoicemenu==1"));
{

System.out.println("1)(For first class type letters 'A' , 'B' ");}


System.out.println("2)(For Business Class type letter 'c','d' ");


System.out.println("3)(For Economy class type , 'E' , 'F' ");
  

  
System.out.println("Choose a option to proceed || Pres '0' to exit to main menu ");
cwChoicemenu = scan.next();
  
String cwChoice=cwChoicemenu;
return cwChoice;
}
  
}

// SeatingSystem.java

public class SeatingSystem {
public static int seatingChart;//This public variable will make the all switch statement to work
//This method will be a boolean statement to make what seats are available and return if it is
//false or true.
public static boolean seatAvailable(char [][] seatingchart, int rwChoice, int cwChoice, int seChoice ,boolean x)
{
switch(seatingChart)
{
case '1':
System.out.println(seatingChart);
System.out.println("rwChoice-1");
break;
case '2': System.out.println(seatingChart);
System.out.println("cwChoice-1");
break;
case '3': System.out.println(seatingChart);
System.out.println("seChoice!=-1");
break;
case'4': if(x) return true;
break;
}
otherwise:
return false;
}
// This method will be an integer and a char statement with a nested
//if else statment to assign the seat
public static int seatAssign(char[][] seatingChart, int rwChoice, int seChoice, int seatingChart2)
{
  
switch(rwChoice)
{
case '1':
if(seatingChart[rwChoice-1][(seChoice-1)]== '*' && rwChoice !=-1 && seChoice!=-1);
else seatingChart[(rwChoice-1)][(seChoice-1)]='x';
break;
case '2':
if(seatingChart[rwChoice-1][(seChoice-1)]== 'x' && rwChoice !=-1 && seChoice!=-1);
else seatingChart[(rwChoice-1)][(seChoice-1)] ='*';
break;
default:
return 1;
}
otherwise:
{
return -1;
}
}
public static int seatUnAssign(char[][] seatingChart, int rwChoice, int seChoice)
{
  
switch(seChoice)
{
case '1':
if(seatingChart[rwChoice-1][(seChoice-1)]== '*' && rwChoice !=-1 && seChoice!=-1);
else seatingChart[(rwChoice-1)][(seChoice-1)]='*';
break;

case '2':
if(seatingChart[rwChoice-1][(seChoice-1)]== '*' && rwChoice !=-1 && seChoice!=0);
else seatingChart[(rwChoice-1)][(seChoice-1)] ='*';
break;
default:
return 0;
}
otherwise:
return 1;
}
// this method will display and print the seating chart
public static void displaySeatingchart(char[][]seatingChart)
{
char x=0;
char y=0;
int count=0;
System.out.println(" A B C D E F");
for(x=0; x <seatingChart.length-1; x++)
if(x <=13)
{
System.out.println("rwChoice" + (x+1)+ " ");
}
else
System.out.println("colChoice" + (x+y)+ " ");
for(y=0; y <seatingChart[x].length; y++)
{
System.out.println(seatingChart[x][y] + " ");
}
if(y+1% 6 ==0)
{   
System.out.println(seatingChart[x][y] + " ");
}
else
{
System.out.println("* ------Available");
}
{
System.out.println("x ------occupied");
System.out.println(" ");
}
count++;

}
}