*****Using C++ in Microsoft Visual Studio***** C&M Airlines (Charlie and Mable)
ID: 651562 • Letter: #
Question
*****Using C++ in Microsoft Visual Studio*****
C&M Airlines (Charlie and Mable) operates a small commuter airline with a single plane that seats 12 passengers. The plane makes one flight per day. Write a seating reservation program as described.
The passenger information is stored in an array of 12 structures. This array should be maintained in the main() function.
Each structure holds the seat ID, a marker that indicates if the seat has been assigned, a passenger first name and a passenger last name. The program repeatedly displays the following menu until Quit is selected.
Choose a function:
a.) Show number of empty seats
b.) Show list of empty seats
c.) Assign a seat
d.) Delete a seat assignment
e.) Quit
Choices c.) and d.) will require additional input from the user; Passenger name for both, and seat number for c.) Checks should be made so that a passenger can
Explanation / Answer
#include "stdafx.h" 02 #include 03 04 /* Find Functions */ 05 void menu(); 06 void showEmptySeats(); 07 08 int _tmain(int argc, _TCHAR* argv[]){ 09 10 /* Create the structure */ 11 typedef struct { 12 char fname[30]; 13 char lname[30]; 14 int id; 15 int taken; 16 } info; 17 18 /* Create the array of 12 structures */ 19 info airplane[12]; 20 21 /* Display the menu */ 22 menu(); 23 24 return 0; 25 } 26 27 void menu(){ 28 29 /* Variable to store the users choice */ 30 char choice[10]; 31 32 /* Menu Options */ 33 printf("a.) Show number of empty seats b.) Show list of empty seats c.) Assign a seat d.) Delete a seat assignment e.) Quit Please choose an option: "); 34 scanf("%s", choice); 35 36 /* Execute function depending on choice */ 37 if(strcmp("a",choice)==0) showEmptySeats(); 38 else if(strcmp("b",choice)==0) printf ("b"); 39 else if(strcmp("c",choice)==0) printf ("c"); 40 else if(strcmp("d",choice)==0) printf ("d"); 41 else if(strcmp("e",choice)==0) printf ("e"); 42 } 43 44 45 void showEmptySeats(){ 46 47 48 };Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.