this is an airline program..seats 1 to 5 go to first class...seats 6 to 10 to economy class...if one class is full the message of choosing another class or wating 3 hours for nexf flight should appear...after 3 days my brain is consumed...heeeelp!!
here is the code
#include <stdio.h>
#define SIZE 10
int main ()
{
int seats[SIZE]= {0}, answer, first =1, economy = 6;
printf( "Welcome to the Airline Reservation System of JFL AIR\n" );
printf( "Choose your desired option:\n" );
printf( "Please type 1 for \"First Class\".\n" );
printf( "Please type 2 for \"Economy\". " );
scanf( "%d", &answer);
while( first <= 5 && economy <= 10){
if ( answer == 1 ) {
seats[first] = 1 ;
printf( "\nYour seat number is: %d, First Class.\n", first);
first++;
}
if( answer == 2) {
seats[economy] = 6 ;
printf( "\nYour seat number is: %d, Economy Class.\n", economy);
economy++;
}
printf( "Please type 1 for \"First Class\".\n" );
printf( "Please type 2 for \"Economy\". " );
scanf( "%d", &answer);
}
while (first == 5 || economy ==10){
if ( first == 5){
printf( "First Class is full.\n" );
printf( "Type 2 for an Economy Seat or Type 3 to wait for next flight\n ");
scanf( "%d", &answer);
}
if ( economy == 10) {
printf( "Economy Class is full.\n" );
printf( "Type 1 for a First Class Seat or Type 3 to wait for next flight.\n ");
scanf( "%d", &answer);
}
if (answer == 3)
printf( "Next flight leaves in 3 hours." );
}
return 0;
}