Question: Write a C++ program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows: 1 A B C D
Write a C++ program to assign passengers seats in an airplane. Assume a small airplane with 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 program should display the seat pattern, with an X marking the seats already assigned. For instance, 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, then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If user types in a seat that is already assigned, the program should say that the seat is occupied and ask for another choice.
Sample Input/Output:
ABC Airlines Seat Map
A B C D A B C D A B C D
A B C D
A B C D
A B C D
A B C D
Reserved seats are marked X. Others are available. Please enter your request in the form 3 C for Row 3, Seat C: 2 B
A B C D
A X C D
A B C D
A B C D
A B C D
A B C D
A B C D
N or n quits, anyting else continues: Y Reserved seats are marked X. Others are available. Please enter your request in the form 3 C for Row 3, Seat C: 3 C
A B C D
A X C D
A B X D
A B C D
A B C D
A B C D
A B C D
N or n quits, anyting else continues: y Reserved seats are marked X. Others are available. Please enter your request in the form 3 C for Row 3, Seat C: 3 C That seat is already reserved. No assignment made. Please make another request
A B C D
A X C D
A B X D
A B C D
A B C D
A B C D
A B C D
N or n quits, anyting else continues: n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
