QuestionQuestion

For this program we will simulate an airplane seating chart system. The program will initially start with an empty airplane. The system will ask seating preferences (such as window, isle seat, section of the plane) as well as how many tickets. Based on availability and seating preferences, the program will choose the seats, display a diagram and the coordinates. The system should also allow for a customer pick a specific seat. Assume that the middle 3 rows in section 2 are wing seats.

Keep in mind:
1. That you should try to group passengers together if they are travelling together
2. If they do not choose specific seats, then choose by preferences
3. You may also want to have a method for placing passengers in the next available spot, if there are no preferences
4. You should display the current availability of the seats (O for Empty, X for occupied)
5. Break down the program into methods as much as possible.

Also store specific details of each passenger, along with their seating chart.

The seating chart can look something like:
                  
             ----------
/                                 \
//                               \\
| OOO               OOO|
| OOO               OOO|       Section 1
| OOO               OOO|
| OOO               OOO|
| OOO               OOO|
| OOO               OOO|
| OOO               OOO|
             |                                  |
| OOO               OOO|
| OOO               OOO|
| OOO               OOO|       Section 2
| OOO               OOO|
| OOO               OOO|
|                                  |
| OOO               OOO|
| OOO               OOO|
| OOO               OOO|       Section 3
| OOO               OOO|
| OOO               OOO|
| OOO               OOO|

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;


public class PlaneManager {

static class Passenger
{
int row, col;
String seatingPref;
char occupied;

public Passenger()
{
occupied = 'O';
}
}

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Passenger[][] seats = new Passenger[18][6];
int passengers, choice;
for(int i = 0; i < seats.length; i++)
for(int j = 0; j < seats[i].length; j++)
seats[i][j] = new Passenger();

while(true)
{
displayPlane(seats);
System.out.println("Welcome to my airline, how many are flying today (0 to exit): ");
passengers = input.nextInt();
if(passengers == 0)
{
System.out.println("Exiting program, goodbye");
break;
}
for(int i = 0; i < passengers; i++)
{
System.out.println("Passenger " + (i+1) + ": Here are some options:");
System.out.println("1. Choose a specific seat");
System.out.println("2. Give a preference");
System.out.println("3. No preference");
System.out.print("Choice: ");
choice = input.nextInt();
if(choice == 1){
if(!specificSeat(seats, input))
i = i-1;
}
else if(choice == 2){
if(!preferredSeat(seats, input))
i = i -1;
}
else if(choice == 3){
if(!noPreference(seats))
i = i-1;
}
else
{
System.out.println("Not a choice, going back to menu");
i= i-1;
continue;
}
}
}
}...
$3.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats