I am trying to write a airline reserve system like program, I have to write a program to assign seats on each flights (10 max for each flight)
u ask the user to type either 1 or 2, 1 for 1st class and 2 for coach.
seats 1-5 is first class and 6-10 is coach, then after they input the type the programs prints out the passengers seat and whether its 1st class or coach.
when 1st class is full, the program should ask if the passenger wants coach or wait for next flight and vise versa. if they want next flight print out next flight leaves in 3 hours.
Code:
#include <stdio.h>
int main()
{
int seats [9],i,type,choice,first=0,econ=5;
printf("Please type 1 for \"first class\"\n");
printf("Please type 2 for \"economy\"\n");
scanf("%d", &type);
for(i=0; i<9; i++)
{
if(type == 1) {
seats[first]=0;
printf("your seat number is %d, first class\n");
first++;
}
if (type == 2) {
seats[econ]=5
printf("Your seat number is %d, economy class\n");
econ++;
}
printf("Please type 1 for \"first class\"\n");
printf("Please type 2 for \"economy\"\n");
scanf("%d", &type);
}
for(i=0; i<9; i++)
if (first == 4) {
printf("Type 2 for economy seat or 3 for another flight\n");
scanf("%d",&choice);
else if (econ ==9) {
printf("Type 1 for first class seat or 3 for another flight\n");
scanf("%d",&choice);
}
if (choice ==3) {
printf("Next flight leaves in 3 hours\n");
}
return 0;
}
I try to write the program but it wont even run for some reason