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 assign seats for a plane. The plane has

ID: 3647876 • Letter: W

Question

Write a C++ program that can be used to assign seats for a plane. The plane has 13 rows, with 6 seats in each row as shown below. Rows 1 and 2 are 1st class, rows 3 to 7 are business class, and row 8 to 13 are economy class. Your program must prompt the user to enter the following information. The ticket type (1st class, business or economy class) Desired seat. Output the seating plan in the following form. * (star) indicates seat is available, and X indicates the seat ios occupied. Make a menu driven program: shows the user choices and allow the user to make the appropriate choicses

Explanation / Answer

#include<stdio.h>

#include<conio.h>

main()

{ char arr[13][6];

for(int i=0;i<13;i++)

{ for(int j=0;j<6;j++)

arr[i][j]='*'; //all seats available in the beginning

}

int c=0,r=0,s=0,ch=0;

do{

cout<<"Availability of seats-";

for(int i=0;i<13;i++)

{ for(int j=0;j<6;j++)

cout<<arr[i][j];

}

cout<<"Please enter the ticket type 1-Firstclass 2-Business 3-Economy";

cin>>s;

cout<<"Please enter the desired seat of the class . Enter row and column separately";

cin>>r;

cin>>c;

if (arr[r-1][c-1]=='*')

arr[r-1][c-1]='X' ;

else

cout<<"Sorry seats are occupied";

cout<<"Do you want to continue? press 1";

cin>>ch;

} while(ch==1)

}//end of main()

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