loop isnt working, along with other switch case issues

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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);		
other part of code that wouldnt fit that goes at the begining

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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;
Last edited on
Topic archived. No new replies allowed.