Question: ** C not C++** Complete the program to assign a seat on an airline flight. The user will select First, Business or Economy class. If

** C not C++** Complete the program to assign a seat on an airline flight. The user will select First, Business or Economy class. If there is an available seat, assign it by adding one to the count of the classs seats and displaying a message. If the assignment fills the selected class, display a message that it is now filled. If there are no available seats in the selected class, display a message. The number of available seats in each class are: First 10 Business 15 Economy 25 You must use a switch block to branch to each seat class's assignment code. Within each seat class section, use if else statement to determine if a seat is available, and when there is a seat, use a further if statement to determine if the class is full after assigning the seat. When the user makes a class selection that is not valid (not one of F, B or E, upper or lower case), display an error message. User entries may be upper or lower case letters. Use the following output messages, exactly. Copy and paste for accuracy. Every output must end with a newline. You were assigned a seat. First class is now full. There are no seats left in First class. Business class is now full. There are no seats left in Business class. Economy class is now full. There are no seats left in Economy class. You made an invalid choice.

#include

int main( ) { char class = ' '; int f_seats = 0; //max 10 int b_seats = 0; //max 15 int e_seats = 0; //max 25 //fill some seats f_seats = 9; b_seats = 15; e_seats = 20; //display menu, get choice printf( "Choose your seat class " ); printf( "F - First class " ); printf( "B - Business class " ); printf( "E - Economy class " ); printf( "Your choice: " ); scanf( "%c", &class ); while(true)

{

printf("For the given seats, enter the option ... ");

printf("First Class -> F or f Business -> B or b Economy Class -> E or e Enter you choice ";

char choice;

scanf("%",%cchoice);

switch(choice)

{

case 'F' : if(First > 0)

{

First--;

printf("You were assigned a seat. ");

// if the seats are now empty

if(First == 0)

printf("First class is now full. ");

}

else

printf("There are no seats left in First class. ");

break;

case 'f' : if(First > 0)

{

First--;

printf("You were assigned a seat. ");

// if the seats are now empty

if(First == 0)

printf("First class is now full. ");

}

else

printf("There are no seats left in First class. ");

break;

case 'B' : if(Business > 0)

{

Business--;

printf("You were assigned a seat. ");

// if the seats are now empty

if(Business == 0)

printf"Business class is now full. ";

}

else

printf("There are no seats left in Business class. ");

break;

case 'b' : if(Business > 0)

{

Business--;

printf("You were assigned a seat. ");

// if the seats are now empty

if(Business == 0)

printf("Business class is now full. ");

}

else

printf("There are no seats left in Business class. ");

break;

// book economy class

case 'E' : if(Economy > 0)

{

Economy--;

printf("You were assigned a seat. ");

// if the seats are now empty

if(Economy == 0)

printf("Economy class is now full. ");

}

else

printf("There are no seats left in Economy class. ");

break;

case 'e' : if(Economy > 0)

{

Economy--;

printf("You were assigned a seat. ");

// if the seats are now empty

if(Economy == 0)

printf("Economy class is now full. ");

}

else

printf("There are no seats left in Economy class. ");

break;

default : printf("You made an invalid choice. ");

break;

}

printf(" To book another seat press y, else n ");

char ch;

scanf("%c",&char);

if(ch != 'y')

break;

} return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!