(Airline Reservations System) A small airline has just purchased a computer for its new au- tomated reservations system. You have been asked to program the new system. You are to write a program to assign seats on each flight of the airline’s only plane (capacity: 10 seats). Your program should display the following menu of alternatives—Please type 1 for "First Class" and Please type 2 for "Economy". If the person types 1, your program should assign a seat in the first class section (seats 1-5). If the person types 2, your program should assign a seat in the economy section (seats 6-10). Your program should print a boarding pass indicating the person’s seat number and whether it is in the first class or economy section of the plane. Use a one-dimensional array to represent the seating ch
What will be an ideal response?
```
#include
#include
using namespace std;
int main()
{
const int SEATS = 11;
int plane[ SEATS ] = {};
int people = 0;
int economy = 6;
int firstClass = 1;
int choice;
char response;
// continue until plane is full
while ( people < 10 )
{
cout << "\nPlease type 1 for \"firstClass\"\n"
<< "Please type 2 for \"economy\"\n";
cin >> choice;
// if user selects first class and seats available, assign seat
if ( choice == 1 )
{
if ( !plane[ firstClass ] && firstClass <= 5 ) // seat available
{
cout << "Your seat assignment is " << firstClass
<< " in the first class section.\n";
plane[ firstClass++ ] = 1;
people++;
} // end if
else if ( firstClass > 5 && economy <= 10 ) // take economy seat
{
cout << "The firstClass section is full.\nWould you "
<< "like to sit in the economy section (Y or N)? ";
cin >> response;
// if economy is suitable, assign seat in economy section
if ( response == 'Y' || response == 'y' )
{
cout << "Your seat assignment is " << economy
<< " in the economy section.\n";
plane[ economy++ ] = 1;
people++;
} // end if
else // if economy seat not suitable, print next departure
cout << "Next flight leaves in 3 hours.\n";
} // end outer else
else // if no economy seats either, print next departure
cout << "Next flight leaves in 3 hours.\n";
} // end outer if
else // if user selects economy and seats available, assign seat
{
if ( !plane[ economy ] && economy <= 10 ) // seat available
{
cout << "Your seat assignment is " << economy
<< " in the economy section.\n";
plane[ economy++ ] = 1;
people++;
} // end if
else if ( firstClass <= 5 ) // first class seat available
{
cout << "The economy section is full.\nWould you like "
<< "to sit in the firstClass section (Y or N)? ";
cin >> response;
if ( response == 'Y' || response == 'y' )
{
cout << "Your seat assignment is " << firstClass
<< " in the first class section.\n";
plane[ firstClass++ ] = 1;
people++;
} // end if
else // if first class not suitable, print next departure
cout << "Next flight leaves in 3 hours.\n";
} // end outer else
else // if no seats left, print next departure
cout << "Next flight leaves in 3 hours.\n";
} // end outer if
} // end while
cout << "All seats for this flight are sold." << endl;
} // end main
```
You might also like to view...
Subfolders are also called ________
A) the File Explorer B) Home folders C) specialized folders D) children
In ____________________ access, the access point device also functions as a point coordinator.
Fill in the blank(s) with the appropriate word(s).