I am a beginner C++ student and I haven't been doing so well in my class.I was wondering if anyone here could help me possibly since my teacher recommended this site.If you can help, thank you very much.
p.s Could you comment on things if they're "advanced" :)
Here is what the code should do:
Write a program to assign passengers seats in an airplane. Assume a small airplane wih seat numbering as follows:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D
The progrram should display the seat pattern, with an 'X' marking the seats already assigned. For example,
after seats 1A, 2B, and 4C are taken, the display should look like this:
1 X B C D
2 A X C D
3 A B C D
4 A B X D
5 A B C D
6 A B C D
7 A B C D
After displaying the seats available, the program prompts for the seat desired, the user types in a seat,
and then the display of available seats is updated. This continues until all seats are filled or until the user signlas that the program should end. If the user types in a seat that is already assigned, the program
should say that that seat is occupied and ask for another choice.
The code I have right now is insufficient so it doesn't work perfectly:
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
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string Seat = "";
string Airline[7][7] = {{"1", "2", "3", "4", "5", "6", "7"}, {"ABCD", "ABCD", "ABCD", "ABCD", "ABCD", "ABCD", "ABCD"}};
char Again = ' ';
int Row = 0;
cout << "Enter a row: ";
cin >> Row;
cout << "Enter a seat: ";
cin >> Seat;
cout << "Enter another seat? (y/n): ";
cin >> Again;
while(Again == 'y')
{
for(int x = 0; x < 7; x++)
{
for(int y = 0; y < 7; y++)
{
cout << "Enter a seat: ";
cin >> Seat;
cout << Airline[y] << endl;
}
cout << "Enter a row: ";
cin >> Row;
cout << Airline[x] << endl;
}
} //end while
system("PAUSE");
return 0;
}
|