Assumng that your user will always enter the proper input (will never happen, so this is purely academic).
Code:
int main(){
int firstClass = 1, coach = 6;
puts("Please enter your section (f = first class, c = coach)");
if(getchar() == 'f'){
if(firstClass != 6){
printf("You are in seat %d", firstClass++);
}else{
puts("First class is full, will you ride coach? (y/n)");
if(getchar() == 'y')
if(coach == 11) printf("Sorry, you've been bumped");
else printf("You are in seat %d", coach++);
else printf("I'm sorry, you're screwed");
}
}else{
if(coach != 11){
printf("You are in seat %d", coach++);
}else{
puts("Coach is full, will you ride first class? (y/n)");
if(getchar() == 'y')
if(firstClass == 6) printf("Sorry, you've been bumped");
else printf("You are in seat %d", firstClass++);
else printf("I'm sorry, you're screwed");
}
}
return 0;
}
Throw this in a loop and you will be all set.
-Prelude