when I try running them, if i go all the way through option one then hit zero, it goes to remove booking menu, then a different display, if i hit option 4, it goes straight to "please enter zero" but it give a different output than it is supposed to do in the do while loop. also i'm wondering how for the edit and remove parts of the menu to start at the file where the booking starts, then write over, while remove to do just that, remove the booking. i assume i have to insert an extra line at the end of the booking menu so it knows when to stop writing over with spaces/deleting.
do{
cout<<"Select an option below (1,2,3,4)"<<endl
<<"1. Add Booking"<<endl
<<"2. Edit Booking"<<endl
<<"3. Remove Booking"<<endl
<<"4. Change Rates"<<endl
<<"5. Check-in/Check-out"<<endl
<<"Press '0' to return to main menu."<<endl;
//cout<<menu.homeMenu<<endl;
cin>>opselect;
switch(opselect){ //switch statement to help with menu selection
case 1:{ //selected add bookin menu
cout<<"If Booked 2 weeks in advanced, 3% off lodging only"<<endl;
cout<<"Please enter book name:"<<endl; //enter book name
cin>>addBook.bookName;
reservationFile<<addBook.bookName; //write book name to reservationFile file
cout<<endl<<"please enter toady's date(yyyymmdd):"<<endl; //enter current date
cin>>addMenu.currentDate;
reservationFile<<addMenu.currentDate; //write current date to reservationfile
cout<<endl<<"please enter start date:(yyyymmdd)"<<endl; //enter start date
cin>>addMenu.startDate;
reservationFile<<addMenu.startDate; //write start date to reservationfile
cout<<"Monthly Rate:"<<showRate.monthRate<<endl //display month rate
<<"Weekly Rate:"<<showRate.weekRate<<endl //display week rate
<<"Daily Rate:"<<showRate.dayRate<<endl; //display day rate
cout<<"Please enter length of stay:"<<endl; //enter length of stay
cin>>addMenu.lengthStay;
reservationFile<<addMenu.lengthStay; //write length of stay to reservation file
cout<<addMenu.lengthStay/30<<"Months"<<endl //use algorithm to find out # of months,weeks, and days
<<addMenu.lengthStay%30/7<<"Weeks"<<endl
<<addMenu.lengthStay%30%7<<"Days"<<endl;
cout<<"Wholesale or Retail?"<<endl
<<"1. Retail"<<endl
<<"2. Wholesale"<<endl;
cin>>mainRateSelect;
switch(mainRateSelect){
case 1:{
cout<<retailRate<<endl;
cout<<"How would you like to pay?"<<endl
<<"1. cash(10%off):"<<endl
<<"2. credit card(8% charge):"<<endl;
cin>>paySelect;
switch(paySelect){
case 1:{
cout<<"Your total cost is:"<<endl
<<retailRate*.9<<endl;
break;
}
case 2:{cout<<"Your total cost is:"<<endl
<<retailRate*1.08<<endl;
break;
}
break;
}break;}
case 2:{
cout<<wholeSaleRate<<endl;
cout<<"How would you like to pay?"<<endl
<<"1. cash(10%off):"<<endl
<<"2. credit card(8% charge):"<<endl;
cin>>paySelect;
switch(paySelect){
case 1:{
cout<<"Your total cost is:"<<endl
<<wholeSaleRate*.9<<endl;
break;
};
case 2:{cout<<"Your total cost is:"<<endl
<<wholeSaleRate*1.08<<endl;
break;
};
}}}
break;
}
cout<<endl<<"Press '0' to return to menu."<<endl;
cin>>returnMenu;
case 2:{ //case to to edit book menu
cout<<"Welcome to the edit booking menu!"<<endl
<<"select booking"<<endl;
reservationFile.seekg(0);
cout<<reservationFile<<*bN;
cin>>addBook.bookName;
reservationFile<<addBook.bookName; //write book name to reservationFile file
cout<<endl<<"please enter toady's date(yyyymmdd):"<<endl; //enter current date
cin>>addMenu.currentDate;
reservationFile<<addMenu.currentDate; //write current date to reservationfile
cout<<endl<<"please enter start date:(yyyymmdd)"<<endl; //enter start date
cin>>addMenu.startDate;
reservationFile<<addMenu.startDate; //write start date to reservationfile
cout<<"Monthly Rate:"<<showRate.monthRate<<endl //display month rate
<<"Weekly Rate:"<<showRate.weekRate<<endl //display week rate
<<"Daily Rate:"<<showRate.dayRate<<endl; //display day rate
cout<<"Please enter length of stay:"<<endl; //enter length of stay
cin>>addMenu.lengthStay;
reservationFile<<addMenu.lengthStay; //write length of stay to reservation file
cout<<addMenu.lengthStay/30<<"Months"<<endl //use algorithm to find out # of months,weeks, and days
<<addMenu.lengthStay%30/7<<"Weeks"<<endl
<<addMenu.lengthStay%30%7<<"Days"<<endl;
cout<<"Wholesale or Retail?"<<endl
<<"1. Wholesale"<<endl
<<"2. Retail"<<endl;
cin>>mainRateSelect;
switch(mainRateSelect){
case 1:{
cout<<wholeSaleRate<<endl;
cout<<"How would you like to pay?"<<endl
<<"1. cash(10%off):"<<endl
<<"2. credit card(8% charge):"<<endl;
cin>>paySelect;
switch(paySelect){
case 1:{
cout<<"Your total cost is:"<<endl
<<wholeSaleRate*.9<<endl;
break;
}
case 2:{cout<<"Your total cost is:"<<endl
<<wholeSaleRate*1.08<<endl;
break;
}
break;}
break;
}
case 2:{
cout<<retailRate<<endl;
cout<<"How would you like to pay?"<<endl
<<"1. cash(10%off):"<<endl
<<"2. credit card(8% charge):"<<endl;
cin>>paySelect;
switch(paySelect){
case 1:{
cout<<"Your total cost is:"<<endl
<<retailRate*.9<<endl;
break;
};
case 2:{cout<<"Your total cost is:"<<endl
<<retailRate*1.08<<endl;
break;
};
}}}break;}}
cout<<"Please press '0' to return to main menu:"<<endl;
cin>>returnMenu;
case 3:{
cout<<"welcome to the remove booking menu!:"<<endl;
break;
}
case 4:{
cout<<"Welcome to the Rate change menu!"<<endl
<<"please select the rate you wish to change"<<endl
<<"1. Month"<<endl
<<"2. Week"<<endl
<<"3. Day"<<endl;
cin>>rateSelect;
switch(rateSelect){
case 1:{
cout<<"Please enter new rate:"<<endl;
cin>>rates.monthChange;
rateFile<<rates.monthChange;
break;
}
case 2:{
cout<<"Please enter new rate:"<<endl;
cin>>rates.weekChange;
rateFile<<rates.weekChange;
break;
}
case 3:{
cout<<"Please enter new rate:"<<endl;
cin>>rates.dayChange;
rateFile<<rates.dayChange;
break;
}}
case 5:{
cout<<"enter book name:"<<endl;
cin>>addBook.bookName;
cout<<addBook.bookName<<endl
<<"1. check in"<<endl
<<"2. Check out"<<endl;
switch(checkSelect){
case 1:{
cout<<addBook.bookName<<"Checked in"<<endl;
break;
}
case 2:{
cout<<addBook.bookName<<"Checked out"<<endl;
break;
}
}}}
cout<<"Please press '0' to return to main menu:"<<endl;
cin>>returnMenu;
break;
}
while(returnMenu==0);
class addBooking{
public:
addBooking();
string addMenu;
string bookName;
int startDate;
int currentDate;
int lengthStay;
}; //add booking class
\
addBooking::addBooking(){
}; //contructor
class rateChange{
public:
rateChange();
int monthChange;
int weekChange;
int dayChange;
};
rateChange::rateChange(){
};
class rates{
public:
rates();
int displayMonthRates();
int displayWeekRates();
int displayDayRates();
int monthRate;
int weekRate;
int dayRate;
};
rates::rates(){
dayRate=100;
weekRate=525;
monthRate=1575;
};
class newUser{ //new user class
public:
newUser();
string name;
string password;
};
newUser::newUser(){ //new user constrctor
};
int main(){
int add=1;
int edit=2;
int remove=3;
newUser newUserOne;
int opselect;
int userselect;
int accesslevel;
int rateSelect;
int paySelect;
rates showRate;
rateChange rates;
int mainRateSelect;
int returnMenu=0;
addBooking addMenu;
addBooking addBook;
string*bN=&addBook.bookName;
int retailRate=((addMenu.lengthStay/30*showRate.monthRate)+(addMenu.lengthStay%30/7*showRate.weekRate)+(addMenu.lengthStay%30%7*showRate.dayRate));
int wholeSaleRate=retailRate*.75;
int checkSelect;
fstream reservationFile; //creating output stream file to write reservation input
reservationFile.open("reservationLog.txt", fstream::in | fstream::out);
(ios::app);
if(reservationFile.fail()){
cout<<"File reservation unsuccessfully opened."<<endl
<<"Please check to see if file exists."<<endl;
exit(1);
}
fstream rateFile;
rateFile.open("rate.txt");
if(rateFile.fail()){
cout<<"File reservation unsuccessfully opened."<<endl
<<"Please check to see if file exists."<<endl;
exit(1);
}
cout<<"File 'rate.txt' opened for writing"<<endl;
fstream userFile; //create output stream file to write user login input
userFile.open("userinfo.txt.");
(ios::app);
if(userFile.fail()){
cout<<"File userinfo unsuccessfully opened."<<endl
<<"Please check to see if file exists."<<endl;
exit(1);
}
cout<<"\n the file userinfo.txt has been successfully opened for writing."<<endl;