Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that can be used to show available seats for a commercial ai

ID: 3931937 • Letter: W

Question

Write a C++ program that can be used to show available seats for a commercial airplane. The airplane has 13 rows with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business class, and rows 8 through 13 are economy class. Output the seating plan in the form shown in Table 0.1. In this table, * indicates that the seat is available; "F", "B", and "E" indicate that a first class, a business class, and an economy class seat is occupied, respectively. You should use a two dimensional character array with elements {,F,B,E}. You can assign hard coded values to this array.

Extra Credit: Instead of "hard coding", your program can prompt the user to enter the following information: a. Ticket type (first class, business class, or economy class) b. Desired seat How to display data as a table in console: To display the table of airplane seating plan, you can use pipe (’|’) to print vertical lines, dash (’-’) to print horizontal lines and plus sign (’+’) to print intersections between horizontal and vertical lines.

Table 0.1: A sample of seating plan

A B C D E F

Row 1 * * F * F F

Row 2 * F * F * F

Row 3 * * B B * B

Row 4 B * * * B *

Row 5 B * * * * B

Row 6 B B * * B B

Row 7 * * B * B B

Row 8 * * B * B B

Row 9 E * E * E *

Row 10 E E E * E *

Row 11 E * E * E E

Row 12 * * E * * *

Row 13 E * E * E E

Explanation / Answer

Please find the required program along with its output. Please see the comments against each line to understand the step.


#include <iostream>
#include <string>
using namespace std;
int main()
{
char seat[13][6] = { //seats array that holds the seats availability
{'*','*','F','*','F','F'},
{'*','F','*','F','*','F'},
{'*','*','B','B','*','B'},
{'B','*','*','*','B','*'},
{'B','*','*','*','*','B'},
{'B','B','*','*','B','B'},
{'*','*','B','*','B','B'},
{'*','*','B','*','B','B'},
{'E','*','E','*','E','*'},
{'E','E','E','*','E','*'},
{'E','*','E','*','E','E'},
{'*','*','E','*','*','*'},
{'E','*','E','*','E','E'}
};
  
  
cout << " A B C D E F"<<endl; //print the header
for(int i=0; i<13; i++){ //outer loop to iterate for the no:of rows
cout << "Row " << i+1 << " " << flush; //print rows side header
for(int j=0; j<6; j++){ //inner loop to iterate for the no:of columns
cout << seat[i][j] << " " << flush; //print the seats availability
}   
cout << endl;
}
  
  

}

-------------------------------------------------

OUTPUT:

A B C D E F
Row 1 * * F * F F
Row 2 * F * F * F
Row 3 * * B B * B
Row 4 B * * * B *
Row 5 B * * * * B
Row 6 B B * * B B
Row 7 * * B * B B
Row 8 * * B * B B
Row 9 E * E * E *
Row 10 E E E * E *
Row 11 E * E * E E
Row 12 * * E * * *
Row 13 E * E * E E

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote