ArrayQuestion).You are to write a program to assingn seats on each flights only plane ( capacity: 10 seats)..
Your program should display the following menu of alternatives..
Please type 1 for First Class
Please type 2 for Economy Class
If the person types 1, then your program should assign a seat in the first class section (seats 1-5).If the person types two , then your program should assign a seat in the economy class (seats 6- 10).Your program should print a bording pass indicating the person's seat number and whether it is in the first class or economy section of the plane.
Use a single-subscript array to represent the seating chart of the plane.Initislize sll the elements of the array to 0 to indicate that all seats are empty.As each seat is assigned, set the corresponding element of the array to 1 to indicate that the seat is no longer available.
Your program should, of course never assign a seat that has already been used.When the first class section is full, your programm should ask the person if it is acceptable to be placed in the economy section( and vise-versa).If yes then make the appropriate seat assingment.If n, then print the message "Nest flight leaves in 3 hours".
this is what i have done so far ..
just some hint and tips would help
Thanks alot ....Code:#include <stdio.h> #include <stdlib.h> #define SIZE 10 int main() { int seats[SIZE] = {0}; int select, i=0, k = 5; char yn; while ( seats[SIZE] > 9 ){ printf( "Please type 1 for First Class." "\nPlease type 2 for Economy Class."); scanf ("%d", &select ); if ( seats[SIZE] > 9 ) printf( "Next Flight leaves in 3 hours\n"); if ( select == 1 ){ ++seats[i++]; if ( seats[i] > 4 ){ { printf ( "Sorry first class is taken do you need economy class"); scanf ("%c", &yn );} if ( yn == 'y' ) ++seats[++k]; else printf ("\nNext Flight leaves in 3 hours"); } } else if ( select == 2 ){ if ( seats[k] > 4 ) printf ("Sorry no more seats"); else ++seats[++k];}} system("PAUSE"); return 0; }