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

Airline Reservation Write a reservation system for an airline flight. Assume the

ID: 3692778 • Letter: A

Question

Airline Reservation Write a reservation system for an airline flight. Assume the airplane has 10 tows with 4 seats in each tow. See Fig. 7.77. Use a two-dimensional any ot strings to maintain a seating chart. In addition, create an arraw to be used as a waiting list in case the plane is full The waiting list should be "first come, first served"; that is, people who are added to the list get over there added later. Allow the user the following three options: (a) Add a passenger to the flight or waiting list. 1.Request the passenger's name. 2.Display a chart of the seats in the airplane in tabular form. 3 if seats are available, let the passenger choose a seat. Add the passenger to the searing chart. 4. If no seats are available, place the passenger on the waiting list.

Explanation / Answer

Answer :   

import java.util.Scanner;
class AirlineRS
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
boolean seats[] = new boolean[10];
int seatsFull = 0,seatFound,seatCount;
for(int i=0;i<10;i++)
{
seats[i] = false;
}
do
{
seatCount = 0;
for(int i=0;i<10;i++)
{
if(seats[i] == false) seatCount++;
}
if(seatCount < 1)
{
System.out.print(" All seats are sold for this flight.");
seatsFull = 1;
break;
}
else
{
System.out.print(" " + seatCount + " seats are availabe.");
}
System.out.print(" Press 1 for first class or 2 for economy class :");
int seatClass = sc.nextInt();
switch(seatClass)
{
case 1: seatFound = 0;
for(int i=0;i<5;i++){ if(seats[i] == false){ seats[i] = true; System.out.print(" Boarding Pass Details -->");
System.out.print(" Seat number :" + (i+1));
System.out.print(" First Class");
seatFound = 1;
break;
}
}
break;
case 2: seatFound = 0;
if(seatFound == 0)
{
for(int i=5;i<10;i++){ if(seats[i] == false){ seats[i] = true; System.out.print(" Boarding Pass Details -->");
System.out.print(" Seat number :" + (i+1));
System.out.print(" Economy Class");
seatFound = 1;
break;
}
}
}
break;
default: System.out.print(" Invalid input...");seatFound = 0;
}
if(seatFound == 0)
{
System.out.print(" No seats availabe in this class, would you like to travel in another class(y/n):");
sc.nextLine();
String changeSeatClass = sc.nextLine();
if(changeSeatClass.equalsIgnoreCase("n"))
{
break;
}
}
}
while(seatsFull != 1);
System.out.print(" Next Flight leaves in 3 hours..");
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote