I need this to be answered I am having so much trouble to answer this problem Wr
ID: 3768398 • Letter: I
Question
I need this to be answered I am having so much trouble to answer this problem
Write a program to solve number 15 on page 637
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
*
*
*
*
*
*
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
import java.util.Scanner; public class Airline { boolean[] seating = new boolean[11]; /* create 10 seat numbers (array[0] will not be used). Empty seat indicated by false*/ Scanner input = new Scanner(System.in); public void start() { while ( true ) { makeReservation(); } } public void makeReservation() { System.out.println("Please type 1 for First Class or 2 for Economy: "); int section = input.nextInt(); if ( section == 1 ) { firstClassSeat(); } else { economySeat(); } } public void firstClassSeat() // assign a first class seat { for ( int count = 1; countRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.