Code:
#include<iostream>
#include<conio.h>
using namespace std;
void waitinglist(int choice, int plane[11]){
cout<<"First Class"<<endl;
cout<<" ---------------------\n";
cout<<" ";
for(int i=1; i<=5; i++){
if(choice == plane[i]){
cout<<"X ";
}
}
}
void waitinglist2(int choice, int plane[11]){
cout<<"\n\nEconomy"<<endl;
cout<<" ---------------------\n";
cout<<" ";
for(int i=1; i<=5; i++){
if(plane[i] == choice){
cout<<"X ";
}
}
}
int main(){
int plane[11]={0};
int i = 0;
int firstclass=1;
int economy = 6;
int choice;
char response[2];
press:
waitinglist(choice,plane);
waitinglist2(choice,plane);
cout<<"\n\n\nPlease type 1 - First class \n";
cout<<"Please type 2 - Economy \n";
while ( i < 10 ) {
cin>>choice;
if(choice == 1){
if(!plane[firstclass] && firstclass<=5){
cout<<"\nReservation Confirmed - Seat# "<<firstclass<<"\n";;
plane[firstclass++]=1;
i++;
getch();
system("cls");
goto press;
}
else if ( firstclass > 5 && economy <= 10 ) {
cout<<"\nThe first class section is full.\n";
cout<<"Would you like to sit in the economy";
cout<<" section ( Y or N )? ";
cin>>response;
if ( response[ 0 ] == 'Y') {
cout<<"\nReservation Confirmed - Seat# "<<economy<<"\n";
plane[ economy++ ] = 1;
i++;
getch();
system("cls");
return main();
}
else {
cout<<"\nNext flight leaves in 3 hours.\n";
getch();
system("cls");
goto press;
}
}
else {
cout<<"\nNext flight leaves in 3 hours.\n";
getch();
system("cls");
return main();
}
}
else {
if ( !plane[ economy ] && economy <= 10 ) {
cout<<"\nReservation Confirmed - Seat# "<<economy<<"\n";
plane[ economy++ ] = 1;
i++;
getch();
system("cls");
goto press;
}
else if ( economy > 10 && firstclass <= 5 ) {
cout<<"\nThe first class section is full.\n";
cout<<"Would you like to sit in the economy";
cout<<" section ( Y or N )? ";
cin>>response;
if ( toupper( response[ 0 ] ) == 'Y' ) {
cout<<"\nReservation Confirmed - Seat# "<<firstclass<<"\n";
plane[ firstclass++ ] = 1;
i++;
getch();
system("cls");
goto press;
}
else {
cout<<"\nNext flight leaves in 3 hours.\n";
getch();
system("cls");
return main();
}
}
else {
cout<<"\nNext flight leaves in 3 hours.\n";
getch();
system("cls");
return main();
}
}
}
cout<<"\nReservation Full\n";
getch();
system("cls");
return main();
return 0;
}
Here is My Code I'm at average of 85%, I'm Stuck in Waiting List....plz need your help!...