(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
```

Computer Science & Information Technology

You might also like to view...

Which of the following is a variable declaration statement?

a. int total; b. #include c. int main() d. // first string entered by user

Computer Science & Information Technology

Select the correct rules for encapsulation. If any rules need to be imposed in a particular order, then say so, mentioning which rules.

a) Make all class member variables public members of the class. b) Place the interface in the header file. What is the interface? c) Place the implementation in a separate code file (with file extension required by your compiler: .cpp, .cxx, etc), called the implementation file. What is the implementation? d) Having private members visible in the interface violates the philosophy of separating the interface from the implementation. Separate interface and implementation requires removal of all the private members from the class definition. You must put these in another part of the class definition in the implementation.

Computer Science & Information Technology

When you need to alter a report's appearance but do not need to see or edit underlying data, you can use ________ view

Fill in the blank(s) with correct word

Computer Science & Information Technology

________ is short for Visual Basic for Applications

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology