Question: -----------CODE FOR ASSIGNMENT---------- 1 // This program assigns seats on an airplane, based on user request, 2 // and displays the layout of the airplane

 -----------CODE FOR ASSIGNMENT---------- 1 // This program assigns seats on an

-----------CODE FOR ASSIGNMENT----------

1 // This program assigns seats on an airplane, based on user request, 2 // and displays the layout of the airplane with occupied seats. 3 import java.util.Scanner; 4 public class A10 { 5 6 // Displays menu and validates user's choice. 7 // Returns a valid choice. 8 public static int displayMenu () { 9 Scanner input = new Scanner(System.in); 10 int choice = 0; 11 boolean valid = false; 12 13 do { 14 // Display the menu 15 System.out.println (); 16 System.out.println ("Please choose an option:"); 17 System.out.println ("1 to pick a seat in economy class"); 18 System.out.println ("2 to view seating chart (horizontal, left)"); 19 System.out.println ("0 to exit"); 20 System.out.print ("? "); 21 22 // Get input and check if it is valid 23 choice = input.nextInt(); 24 System.out.println (); 25 if (choice >= 0 && choice lastSeat)) 46 System.out.println ("Seats in " + service + " class must be between " + firstSeat + " and " + lastSeat + "."); 47 else 48 // Check if seat is occupied. 49 if (seatsArray[seat]) 50 System.out.println ("Seat " + seat + " is already occupied."); 51 else { 52 seatsArray[seat] = true; 53 System.out.println ("Seat " + seat + " successfully assigned."); 54 } 55 } 56 57 // Displays the current seat availability stored in the 58 // boolean array passed as a parameter. 59 // Assumes a 3x10 seat configuration. Displays plane horizontally. 60 public static void viewSeatingChartLeft (boolean[] seatsArray) { 61 62 // Print right wing and side 63 System.out.println (" /|"); 64 System.out.println (" / |"); 65 System.out.println (" / | /|"); 66 System.out.println (" ________/ |________/ |"); 67 System.out.println (" / |"); 68 69 // Print right side window seats (3, 6, 9, ...) 70 System.out.print (" / "); 71 for (int i = 3; i "); 88 89 // Print left side window seats (1, 4, 7, ...) 90 System.out.print (" \\ "); 91 for (int i = 1; i 0); 133 } 134 }

----------SAMPLE OUTPUT-------------

airplane, based on user request, 2 // and displays the layout of

In this assignment, you will add more functionality to an airine reservation system. The starting program assigns seats on a small airplane 30 seats: 10 rows with 3 seatsach It an ently displays the folowing menu f alternatives: Plase choose an aption 1 to pick a seat in economy class 2 to view seating chart (honzontal lett) 0 to exit Your jab is to change the menu, change some of code in the existing methods, and create new melhods to handle the new menu options. You also need to change the sze of the plane to accommodate 90 seats (30 rows of 3 seats each). The new menu must look like the following Please choose an option 1 to pick seat in economy class 2 to cancel a seat reservation 3 to see a passenger's seat number 4 to see a seat's passenger's name 5 to viaw seating chart (honzontal, let) 6 to view seating chart (hoizontal, right 0 to exit If the user types 1, then the program asks for a scat number in the cconomy class section (seats 1-90 Your program needs to yaldade that the user entered a valid seat number and Check-the seat is empty before assigning it Your program should not assign a seat that has already been assigned .When a assigning a seat, besides marking the seat number as occupied (in the array of seats), the program must also .Ask for the passenger's name .Keep the passenger names in a separate aray (of Strings). Hint: store the name in the array position comesponding to the seat assignment if the user types 2, then the program allows the userto cancel a previously assigned seat. " Rernember to update both arrays (seats and names). .It the user types 3, then the program asks the user to encer a passengers name. The program then displays that passengers seat number.IM multiple passengers have the same name, show all the seats that match the name If the user types 4, then the program asks the user to enter a seat number. The programs then displays the name af the passenger in that seat, or "empty seat" if nabody is in that seat It the user types 5, then the program displays the seat map ot plane, honzontally, pointing to the let. For example: Seat 4 Seat 4 lf the user types 6, then the program displays the seat map o plane, ho Zonta y, pointing to the right. Th seats are pnnted in the correct order a ated vers n o the left porting ayout), or example see seat 4 marked th an x above and below Seat 4 Seat 4 Please see the sampla output for clanfication on the program behavicr Your pregram must: Print a welcome message from your arline-include the airine name (your choice, but try to make it unique). .Display the menu, get a number from the user, perfonm the requested action, then display the menu again, and cononue this loop untl the user chooses option 0. Valdate that the number entered by the user is a valid option. You may assume the user will always enter an integer (except for names), therefore you do not need to check for invalid characters. But you need to check whether the integer is within the valld range. It the user enters an rvalid option (-1, 94, 155...), display an error message, then display the menu again In this assignment, you will add more functionality to an airine reservation system. The starting program assigns seats on a small airplane 30 seats: 10 rows with 3 seatsach It an ently displays the folowing menu f alternatives: Plase choose an aption 1 to pick a seat in economy class 2 to view seating chart (honzontal lett) 0 to exit Your jab is to change the menu, change some of code in the existing methods, and create new melhods to handle the new menu options. You also need to change the sze of the plane to accommodate 90 seats (30 rows of 3 seats each). The new menu must look like the following Please choose an option 1 to pick seat in economy class 2 to cancel a seat reservation 3 to see a passenger's seat number 4 to see a seat's passenger's name 5 to viaw seating chart (honzontal, let) 6 to view seating chart (hoizontal, right 0 to exit If the user types 1, then the program asks for a scat number in the cconomy class section (seats 1-90 Your program needs to yaldade that the user entered a valid seat number and Check-the seat is empty before assigning it Your program should not assign a seat that has already been assigned .When a assigning a seat, besides marking the seat number as occupied (in the array of seats), the program must also .Ask for the passenger's name .Keep the passenger names in a separate aray (of Strings). Hint: store the name in the array position comesponding to the seat assignment if the user types 2, then the program allows the userto cancel a previously assigned seat. " Rernember to update both arrays (seats and names). .It the user types 3, then the program asks the user to encer a passengers name. The program then displays that passengers seat number.IM multiple passengers have the same name, show all the seats that match the name If the user types 4, then the program asks the user to enter a seat number. The programs then displays the name af the passenger in that seat, or "empty seat" if nabody is in that seat It the user types 5, then the program displays the seat map ot plane, honzontally, pointing to the let. For example: Seat 4 Seat 4 lf the user types 6, then the program displays the seat map o plane, ho Zonta y, pointing to the right. Th seats are pnnted in the correct order a ated vers n o the left porting ayout), or example see seat 4 marked th an x above and below Seat 4 Seat 4 Please see the sampla output for clanfication on the program behavicr Your pregram must: Print a welcome message from your arline-include the airine name (your choice, but try to make it unique). .Display the menu, get a number from the user, perfonm the requested action, then display the menu again, and cononue this loop untl the user chooses option 0. Valdate that the number entered by the user is a valid option. You may assume the user will always enter an integer (except for names), therefore you do not need to check for invalid characters. But you need to check whether the integer is within the valld range. It the user enters an rvalid option (-1, 94, 155...), display an error message, then display the menu again

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!