How come the information is not passing to txt file
Code:PHP Code:void hotel::submenu() { information n; char choose; int number=0; int room; char continues; outfile.open (filename,ios::out|ios::app); int single=100; int doubler=200; int triple=300; cout<<"*******************"<<endl; cout<<"Check In"<<endl; cout<<"--------------- "<<endl; cout<<"S->Single"<<endl; cout<<"D->Double"<<endl; cout<<"T->Triple"<<endl; cout<<"Q->Quit "<<endl; cout<<"*******************"<<endl; cout<<"Enter the Type of Room you want: "<<endl; cin>>choose; cin.get(); choose=(char)toupper(choose); n.type_room=choose; int account_s=0; int account_d=0; int account_t=0; int r_number; char type; string r_name; string r_family; string r_city; string r_telephone; int r_time; double r_price; if (choose=='S'||choose=='D'||choose=='T') { infile.open(filename,ios::in); if (infile==NULL) cout<<"Error opening the file"<<endl; while(!infile.eof()) { infile>>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time; if(type=='S') { account_s++; } if (type=='D') { account_d++; } if (type=='T') { account_t++; } } single=single-account_s; doubler=doubler-account_d; triple=triple-account_t; infile.close(); if (type=='S') { single=single+1; } if (type=='D') { doubler=doubler+1; } if (type=='T') { triple=triple+1; } if (n.type_room=='S') { if (single!=0) { cout<<"Total single bed available is "<<single; cout<<"\nHow many single bed you need?"; cin>>number; } else { cout<<"\nSorry,No Room available."; } } if (n.type_room=='D') { if (doubler!=0) { cout<<"Total double bed available is "<<doubler; cout<<"\nHow many double bed you need?"; cin>>number; } else { cout<<"\nSorry,no room available."; } } if (n.type_room=='T') { if (triple!=0) { cout<<"Total triple bed available is "<<triple; cout<<"\nHow many bed you need?"; cin>>number; } else { cout<<"Sorry,no any room Available."; } } cin.get(); cout<<"First Name : "; cin>>n.name; cout<<"Family Name : "; cin>>n.family; cout<<"City : "; cin>>n.city; cout<<"Tel : "; cin>>n.telephone; cout<<"Charge :"; cin>>n.cost_perday; cout<<"Days : "; cin>>n.time; int flag=0; for (int i=1;i<=number;i++) { cout<<"Room NO.: "<<endl; cin>>room; if (n.type_room=='S') { if(room<100 || room>199) { cout<<"You Should Choose The Number Between 100 And 199"<<endl; cout<<endl; i=i-1; continue; } infile.open(filename,ios::in); while (!infile.eof()) { infile>>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time; if (room==r_number) { cout<<"You Should Choose Other Room.This is occupied."<<endl; cout<<endl; flag=1; i=i-1; break; } else { flag=0; } } infile.close(); if (flag==1) { continue; } } if (n.type_room=='D') { if(room<200 || room>399) { cout<<"YOU Should Choose The Number Between 200 And 399"<<endl; cout<<endl; i=i-1; continue; } infile.open(filename,ios::in); while (!infile.eof()) { infile>>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time; if (room==r_number) { cout<<"You must choose other room.This is occupied."<<endl; cout<<endl; flag=1; i=i-1; break; } else { flag=0; } } infile.close(); if (flag==1) { continue; } if (n.type_room=='T') { if(room<400 || room>499) { cout<<"You should Choose The Number Between 400 And 499"<<endl; cout<<endl; i=i-1; continue; } infile.open(filename,ios::in); while (!infile.eof()) { infile>>r_number>>r_name>>r_family>>r_city>>r_telephone>>type>>r_price>>r_time; if (room==r_number) { cout<<"You Should choose other room.This is occupied."<<endl; cout<<endl; flag=1; i=i-1; break; } else { flag=0; } } infile.close(); if(flag==1) { continue; } } outfile.open (filename,ios::out|ios::app); outfile<<room<<" "; outfile<<n.name<<" "; outfile<<n.family<<" "; outfile<<n.city<<" "; outfile<<n.telephone<<" "; outfile<<n.type_room<<" "; outfile<<n.cost_perday<<" "; outfile<<n.time<<endl; outfile.close(); } cout<<"The Check In Is Finished"<<endl; cout<<endl; } if (choose=='Q') { main(); } cout<<"Another Check In (Y/N)"<<endl; cin>>continues; if(continues=='y'||continues=='Y') main(); } }



LinkBack URL
About LinkBacks


