Question: Java programming 5th edition chapter 9 two dimensional arrays Write a program that can be used to assign seats for a commercial airplane. The airplane

Java programming 5th edition chapter 9 two dimensional arrays

Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, rows 8 through 13 are economy class.

The program should be menu driven (with a loop) as follows:

Main Menu

1.Display Seating Plan

2. Choose a seat

3. Exit

The seating plan should display:

The lines are there just so you can see them

________A___B___C___D___E___F

Row 1___*___*____X___*____X__X

Row 2 __*___X____*___X____*__X

Row 3 __*___*____X___X____*__X

Etc.

The * indicates the seat is available. The X indicates the seat is taken.The chart will begin with all *'s as all seats are empty.

When choosing a seat, the user will enter the seat ID, for example C5, and the program will check to see if that seat is available. Is so, it will mark that seat as taken, display the seat ID with the class and seat type designation (for example, F4 is a Window seat in Business class). If not, it will display a 'seat taken' message and let the user choose another seat.

Test the program:

Display the seating plan (it should have all*)

Choose seats A9, B4, E1, D13, C7, F4, D13, D4, B9, E4, A12, B4

Display the seating plan again (make sure it is correct)

This is what I have so far which isn't much.

import java.util.*;

public class AssignSeats { static Scanner console = new Scanner(System.in); public static void main(String[]args) { //Declare variables int choice = 0; //Declare 2D Arrays int rows = 13; int seatCol = 6; int matrix = new int[rows][seatCol]; menuDisplay(); choice = console.nextInt(); while(choice != 3) { menuDisplay(); choice = console.nextInt(); } }//end main public static void menuDisplay() { System.out.println("Main Menu"); System.out.println("1. Display Seating Plan"); System.out.println("2. Choose a seat"); System.out.println("3. Exit");

}//end menuDisplay public static void planeLayout() { System.out.println("A" + "B" + "C" + "D" + "F"); for (int row = 0; row < 13; row++) System.out.print(row + 1); for (int seatCol = 0; seatCol < 6; seatCol++) }//end planeLayout }//end class

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!