(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 chart of the plane. Initialize all the ele- ments of the array to false to indicate that all seats are empty. As each seat is assigned, set the cor- responding elements of the array to true to indicate that the seat is no longer available. Your program should, of course, never assign a seat that has already been assigned. When the first class section is full, your program should ask the person if it is acceptable to be placed in the economy section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message "Next flight leaves in 3 hours."
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
```
Please type 1 for "firstClass"
Please type 2 for "economy"
1
Your seat assignment is 1 in the first class section.
Please type 1 for "firstClass"
Please type 2 for "economy"
2
Your seat assignment is 6 in the economy section.
Please type 1 for "firstClass"
Please type 2 for "economy"
...
Please type 1 for "firstClass"
Please type 2 for "economy"
2
The economy section is full.
Would you like to sit in the firstClass section (Y or N)? Y
Your seat assignment is 5 in the first class section.
All seats for this flight are sold.
You might also like to view...
If userA sends a secure message to userB using an asymmetric cryptographic algorithm, and userB sends a reply, what key is used if userA wants another user, userC to read the reply message?
A. userB's private key B. userC's public key C. userA's public key D. userC's private key
Which of the following is NOT true about modifying axes?
A) Excel knows best in regard to formatting the axes; thus, if it seems to crowded, it probably is not. B) The Format Axis task pane can be used to manually set the axis options. C) The x-axis and y-axis scales are automatically created through a mathematical algorithm within Excel. D) The default Excel scale minimum and maximum values are set automatically on the basis of the data.
A(n) ____________________ is a set of predefined styles for a particular type of document, e.g., memo or letter.
Fill in the blank(s) with the appropriate word(s).
A virus signature is a portion of virus code that is unique to a particular computer virus.
Answer the following statement true (T) or false (F)