i really need help i was absent in this class (arrays) and i dont know what to do :( i have an assignment due on sunday :"(!! i asked the doctor if he explain to me what i missed but he refused... so pleeaaase if u guys can help me with this q!
*Airline Reservation
A very small airline owns a small aircraft with a capacity of 10 seats. Write a program that keeps track of flight reservations. Your program should display the following:
Would you like to make a reservation? Enter Y for yes or N for no. (Your program executes until the user answers no). Each time the user answers yes, the following menu should be displayed:
Please type 1 for smoking
Please type 2 for nonsmoking.
If the person types 1, then your program should assign a seat in the smoking section (seats 1-5). If the person types 2, then the program should assign a seat in the section 6-10. Your program should then print a boarding pass indicating the seat number and whether it is in the smoking or the nonsmoking section.
Use an array to represent the seating chart of the airplane. Initialize all the elements of the array to zero indicating that all seats are available. As each seat is assigned, set the corresponding element to 1 to indicate that the seat is no longer available.
Your program should never assign a seat that has already been assigned. When the smoking section is full your program should display the message “Sorry, the smoking area is full. Try the nonsmoking area”. Similarly, if the nonsmoking section is full, your program should display “Sorry, the nonsmoking area is full.Try the nonsmoking area”.
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
|
# include <iostream>
# include <iomanip>
# include <cstring>
using namespace std;
int main()
{
int seats [10] = {0};
char Y;
char N;
char y;
char n;
char answer1;
int answer2;
int smoking = 1;
int nonSmoking = 2;
for ( int i = 0; i < 10; i++)
{
cout << "Would like to make reservation? Enter Y for yes, N for no:"<< endl;
cin >> answer1;
if ( answer1 == 'y' )
cout << " Please enter 1 for smoking, 2 for nonsmoking:"<< endl;
cin >> answer2;
if ( answer2 == 1)
{
for (i = 0; i <= 5; i++)
{
if (seats[i] == 0 )
{
[i] = 1;
cout << " boarding pass:"<< endl;
cout << " Seat:" << " " << i+1 << endl;
cout << " Area" << " " << " nonsmoking"<< endl;
}
}
}
else if ( answer2 == 2)
{
for ( i = 6; i<= 10; i++)
{
if (seats[i] == 0)
{
[i] = 1;
cout << " boarding pass:"<< endl;
cout << " Seat:" << " " << i+1 << endl;
cout << " Area" << " " << " smoking "<< endl
}
}
}
}
return 0;
}
|
thats what i did so far and i have an error and i dont know what to do :( plz helppp