1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#include <iostream>
using namespace std;
void firstClass (int i=0, int j=0, char alt);
void economyClass (int j=0, int i=0, char alt);
int main ()
{
int selection, i=0, j=0;
char alt;
cout << "Please select your preferred class. Enter 1 for first class, or 2 for economy class: " ;
cin >> selection;
if (selection == 1)
{
firstClass (i=0, j=0, alt);
}
else if (selection == 2)
{
economyClass (j=0, i=0, alt);
}
return 0;
}
void firstClass (int i=0, int j=0, char alt)
{
if (i <= 5)
{
cout << "Your seat assignment is seat number " << i << " in the first class section." << endl;
i++;
}
else if (i > 5)
{
cout << "First class seating is full. Would you like a seat in economy class? Enter Y for yes or N for no: " << endl;
cin >> alt;
{
if (alt == 'Y')
{
economyClass (j=0, i=0, alt);
}
else if (alt == 'N')
cout << "The next flight leaves in 3 hours." << endl;
}
}
}
void economyClass (int j=0, int i=0, char alt)
{
if (j <= 5)
{
cout << "Your seat assignment is seat number " << j << " in the first class section." << endl;
j++;
}
else if (j > 5)
{
cout << "Economy class seating is full. Would you like a seat in first class? Enter Y for yes or N for no: " << endl;
cin >> alt;
{
if (alt == 'Y')
{
firstClass (i=0, j=0, alt);
}
else if (alt == 'N')
cout << "The next flight leaves in 3 hours." << endl;
}
}
}
| |