i have a plane w/10 seats 5 1st class 5 economy and when one is full u ask if it is alright to putin the oppoiste one and if not you say next flight in 3 hrs and i dont know what happened w/this thing
this thing is driving me nuts
help?
i have a plane w/10 seats 5 1st class 5 economy and when one is full u ask if it is alright to putin the oppoiste one and if not you say next flight in 3 hrs and i dont know what happened w/this thing
this thing is driving me nuts
help?
Try to take a deep breath between each sentance and explain your problem again.
Hopefully this will help us understand whatever your problem is.
/Laos
My program is a plane w/ten seats and 5 r 1st class 5 r economy
u choose 1 for 1st and 2 for economy and when all five in one of the sections is full u ask the user to say yes to whether or not it is okay to put them in the other section my problem is that when all of the spaces is full in one of the classes it totally ends w/o asking to be put in the other section or not and i cant figure out this stupid thing i think i have a few other bugs in this thing like when i did have my question to go to another class it would reassign an assigned seat and econ would wind up in a infinite loop after the ? i fixed the code a little could anyone possibly help me
fixed program:
Nasty code you had there edshaft, normally I don't have any problem following the logic but your program gave me fits
Anyway, it works now. Let me know if you have any more questions.
-PreludeCode:#include <iostream> using namespace std; int first(int& i, int& j, int flagFirst, int flagEcon); int econ(int& i, int& j, int flagFirst, int flagEcon); int main() { int assign, i = 1, j = 1, flagFirst = 0, flagEcon = 0; while(flagFirst != 1 && flagEcon != 1){ cout<<"Please type 1 for First Class\n"; cout<<"Please type 2 for Economy\n"; cin>>assign; if (assign == 1){ first(i, j, flagFirst, flagEcon); } else{ econ(i, j, flagFirst, flagEcon); } } return 0; } int first(int& i, int& j, int flagFirst, int flagEcon){ char non; if(flagFirst == 1 && flagEcon == 1){ cout<<"All seats are full"<<endl; exit(0); } if(i > 5){ flagFirst = 1; cout<<"First class is full. Is it all right to place you in nonsmoking?(y/n)\n"<<flush; cin>> non; if(non=='y'|| non == 'Y'){ econ(i, j, flagFirst, flagEcon); } else cout<<"Next flight in three hours\n"; } else{ flagFirst = 0; cout<<"You are in seat "<<i++<<" in first class\n"; } return 0; } int econ(int& i, int& j, int flagFirst, int flagEcon){ char non; if(flagFirst == 1 && flagEcon == 1){ cout<<"All seats are full"<<endl; exit(0); } if(j > 5){ flagEcon = 1; cout<<"Economy is full. Is it all right to place you in smoking?(y/n)\n"<<flush; cin>> non; if(non=='y'|| non == 'Y'){ first(i, j, flagFirst, flagEcon); } else cout<<"Next flight in three hours\n"; } else{ flagEcon = 0; cout<<"You are in seat "<<j++<<" in economy\n"; } return 0; }
My best code is written with the delete key.
well the code works but i actually need it to work with one array instead of the flagfirst and flagecon you used
the array is seat[10]
i tried to fix it but im screwed up once again and if anyone helps that would be wonderful
the despriction of how it works is the same it is just that i need it to work w/that array