Won't run past inital selection

Apr 24, 2013 at 2:54am
I can't get this to run past the initial selection. Any ideas?
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
 #include <iostream>
#include<time.h>
using namespace std;

	
		//function prototypes
		int get_ticket_type(int);
		double find_ticket_price(int);
		double apply_discount(double, double);
		void disp_purchase(int, int, double);
		void disp_final_report(int, double, int, int, int, double);


	int main()
	{
		
		int SEAT_COUNT = 0;
		int MAX_SEAT_COUNT = 16;
		int option = 1;
		int Total_Sold = 0;
		int not_for_toddlers;
		int not_for_juniors;
		int not_for_adults;
		int TODDLERS = 0;
		int JUNIORS = 0;
		int ADULTS = 0;		
		double Gross_total = 0.0;
		int gtp = 0;
		int nof_seat = 0;
		double ftp = 0.0;
		double price;
		double disPrice = 0.0;
		double toPrice = 0.0;
		
		while (option != 5 && SEAT_COUNT < MAX_SEAT_COUNT)
		{
			gtp = get_ticket_type(option);

			if(gtp==5)
			{	
				break;
			}
				
			if(gtp==4)
			{
				system("CLS");
			}
		
			ftp = find_ticket_price(gtp);
		
			if(gtp > 1 && gtp < 4)
			{
				
				switch(gtp)
				{
				case 1:
					cout << "How many tickets do you want for toddlers?\n";
					cin >> not_for_toddlers;
			
					if(not_for_toddlers <= 10)
					{
						SEAT_COUNT = SEAT_COUNT - not_for_toddlers;
						TODDLERS = TODDLERS + not_for_toddlers;
						Total_Sold = Total_Sold + not_for_toddlers;
						price = not_for_toddlers * ftp;
						nof_seat = not_for_toddlers;
						system("pause");
						
					}
	
					else
					{	
						cout <<"You are only allowed 10 tickets\n";

						SEAT_COUNT = SEAT_COUNT - 10;
						TODDLERS = TODDLERS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * ftp;
						nof_seat = 10;
						system("pause");
						
					}break;

				case 2:
					cout << "How many tickets do you want for juniors?\n";
					cin >>not_for_juniors;

					if(not_for_juniors <= 10)
					{
						SEAT_COUNT = SEAT_COUNT - not_for_juniors;
						JUNIORS = JUNIORS +  not_for_juniors;
						Total_Sold = Total_Sold + not_for_juniors;
						price = not_for_juniors * ftp;
						nof_seat = not_for_juniors;
						system("pause");
					}
	
					else
					{
						cout <<"You are only allowed 10 tickets\n";
				
						SEAT_COUNT = SEAT_COUNT - 10;						
						JUNIORS = JUNIORS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * ftp;
						nof_seat = 10;
						system("pause");				
					}break;			

				case 3:

					cout << "How many tickets do you want for adults?\n";
					cin >>not_for_adults;

					if(not_for_adults <= 10)
					{

						SEAT_COUNT = SEAT_COUNT - not_for_adults;						
						ADULTS = ADULTS + not_for_adults;
						Total_Sold = Total_Sold + not_for_adults;
						price = not_for_adults * ftp;
						nof_seat = not_for_adults;
						system("pause");
						
					}

					else
					{
						cout <<"You are only allowed 10 tickets\n";
				
						SEAT_COUNT = SEAT_COUNT - 10;						
						ADULTS = ADULTS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * ftp;
						nof_seat = 10;
						system("pause");						
					}break;					
	
			}


				disPrice = apply_discount(price, Gross_total);
				disp_purchase(option, nof_seat, disPrice);
			}
		  
			if (Total_Sold >= MAX_SEAT_COUNT)
		  	{
		  		system("CLS");
		  		disp_final_report(MAX_SEAT_COUNT, Total_Sold, TODDLERS, JUNIORS, ADULTS, Gross_total);
				system("pause");
		  		
		  	}
			
			else
			{
				return 0;
			}
		}
	}
  
	//open get_ticket_type()
  	
	int get_ticket_type(int)
	{
		
		int option;
				
		
			cout <<"Summerville SeaWorld Ticket Sales v1.02\n";
			cout <<"--------------------------------------\n";
  			cout <<"Enter the following details for ticket sales:\n";
  			cout <<"*********************************************************\n";
			cout << "Ticket Menu"<<endl;
	   		cout << "----------"<<endl;
	   		cout << "1. Toddlers"<<endl;
	   		cout << "2. Juniors"<<endl;
	   		cout << "3. Adults"<<endl;
	   		cout << "4. Clear Screen"<<endl;
	   		cout << "5. Quit"<<endl;
			cin >> option;
			system("pause");
	   
				   		
			if(option>0 && option<=4  )
			{
				return option;
				system("pause");
			}
	   
			else if(option=5)
			{
				return 5;
				system("pause");
			} 

			else 
			{
				cout << "Please enter a valid option!\n";
				system("pause");
			}

				 
		system("pause");
	 	
	}//close get_ticket_type()

  	double find_ticket_price(int gtp)
	{
		int x = gtp;
		double price = 0.0;
		
		if(x==1)
		{
			double price = 0.0;
			return price;
		}
		
		if(x==2)
		{
		 	double price = 7.50;
			return price;
		}
		
		if(x==3)
		{
			double price = 11.50;
			return price;
		}
		
		return price;
			      
	}//close find_ticket_price

   	double apply_discount(double price, double Gross_total)
	{
	 	
		double toPrice = price;
		double discountedPrice = 0.0;
		double discount = 0.0;
		char coupon;
		
		cout << "Do you have a discount coupon? (y/n) "<<endl;
	 	cin >> coupon;
	 
		if(coupon == 'y' || 'Y')
		{
			discount= price * 0.25;
			discountedPrice = toPrice - discount;
			Gross_total = Gross_total + discountedPrice;
			return discountedPrice;
			system("pause");
		}
	 	else
	        {
	       		Gross_total = Gross_total + price;
				return toPrice;
				system("pause");
	       	}

		
	 }//close apply_discount
      
	void disp_purchase(int option, int nof_seat, double disPrice)
	{
		int y = option;
		double z = disPrice;

		cout <<"\nWelcome to Summerville SeaWorld"<<endl;
		cout << "------------------------------------------"<<endl;
		cout << "Ticket Details:"<<endl;
		cout << "---------------"<<endl;
	 
		if(y==1)
		{
			cout << "Toddler Tickets"<<endl;
		}
	 	
		if(y==2)
		{
			cout << "Junior Tickets"<<endl;
		}
	 
		if(y==3)
		{
			cout << "Adult Tickets"<<endl;
		}
		
		cout <<"The number of tickets purchased: "<<nof_seat;
	 
		if(disPrice==z)
		{
			cout << "\nYour total amount is $" <<disPrice<<endl;
		}
	 	else
		{
			cout << "\nYour total amount after discount is $" <<disPrice<<endl;
		}
	 	
		cout << "------------------------------------------\n";
	 	
	}// close disp_purchase

   	void disp_final_report(int MAX_SEAT_COUNT, double Total_Sold, int TODDLERS, int JUNIORS, int ADULTS, double Gross_total)
	{
		char tmpbuf[128];
				
		time_t now;
		time(&now);
		cout <<"******************************************************\n";
		cout << "TICKET SALES REPORT FOR DATE:"<<  _strdate_s(tmpbuf);
		cout <<"------------------------------------------------------\n";
		cout << "SEAT CAPACITY\tLEFT\t\tTOTAL SOLD\n";
		cout <<"---------------------------------------\n";
		cout <<MAX_SEAT_COUNT<<"\t\t"<<(MAX_SEAT_COUNT-Total_Sold)<<"\t\t"<<Total_Sold<<"\n";
		cout <<"---------------------------------------\n";
		cout << "TODDLERS\tJUNIORS\t\tADULTS \n";
		cout <<"---------------------------------------\n";
		cout <<  TODDLERS<<"\t\t"<<JUNIORS<<"\t\t"<<ADULTS<<"\n";
		cout <<"---------------------------------------\n";
		cout << "GROSS FOR TODAY: $"<<Gross_total<<"\n";
		cout <<"***************************************\n";
		cout << "Press any key to exit..."<<endl;
	
	
	 }//close disp_final_report
Apr 24, 2013 at 3:33am
get rid of
154
155
156
157
else
{
	return 0;
}
Apr 24, 2013 at 9:39am
now it doesn't go past the initial selection. must be a problem somewhere else.
Apr 25, 2013 at 4:55pm
I've reworked it a little, since I'm more familiar with functions now. I'm having a problem with the data types I'm trying to pass, but I can't figure it out. Any ideas?

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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339

/************************************************************/
/* FILENAME : program6SolutionLangdon.cpp                   */
/* PROGRAMMER: Amy Langdon                                  */
/* PURPOSE : To track ticket sales for Summerville SeaWorld */
/************************************************************/



#include <iostream>
#include<time.h>
using namespace std;

	
		//function prototypes
		int get_ticket_type(int &option);
		double find_ticket_price(int &option, double &price);
		double apply_discount(double &price, double &Gross_total);
		void disp_purchase(int &option, int &nof_seat, double &disPrice);
		void disp_final_report(int &MAX_SEAT_COUNT, double &Total_Sold, int &TODDLERS, int &JUNIORS, int &ADULTS, double &Gross_total);


	int main()
	{
		
		int SEAT_COUNT = 0;
		int MAX_SEAT_COUNT = 16;
		int option = 1;
		int Total_Sold = 0;
		int not_for_toddlers;
		int not_for_juniors;
		int not_for_adults;
		int TODDLERS = 0;
		int JUNIORS = 0;
		int ADULTS = 0;	
		double Gross_total = 0.0;
		int nof_seat = 0;
		double price = 0.0;
		double disPrice = 0.0;
		char cont = '\0';
 		const char SENTINEL = 'q';
		
		while (cont != SENTINEL)
		{
		
		while (option != 5 && SEAT_COUNT < MAX_SEAT_COUNT)
		{
			get_ticket_type(&option);

			if(option==5)
			{	
				break;
			}
				
			if(option==4)
			{
				system("CLS");
			}
		
			find_ticket_price(&option, &price);
		
			if(option > 1 && option < 4)
			{
				
				switch(option)
				{
				case 1:
					cout << "How many tickets do you want for toddlers?\n";
					cin >> not_for_toddlers;
			
					if(not_for_toddlers <= 10)
					{
						SEAT_COUNT = SEAT_COUNT - not_for_toddlers;
						TODDLERS = TODDLERS + not_for_toddlers;
						Total_Sold = Total_Sold + not_for_toddlers;
						price = not_for_toddlers * price;
						nof_seat = not_for_toddlers;
						system("pause");
						
					}
	
					else
					{	
						cout <<"You are only allowed 10 tickets\n";

						SEAT_COUNT = SEAT_COUNT - 10;
						TODDLERS = TODDLERS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * price;
						nof_seat = 10;
						system("pause");
						
					}break;

				case 2:
					cout << "How many tickets do you want for juniors?\n";
					cin >>not_for_juniors;

					if(not_for_juniors <= 10)
					{
						SEAT_COUNT = SEAT_COUNT - not_for_juniors;
						JUNIORS = JUNIORS +  not_for_juniors;
						Total_Sold = Total_Sold + not_for_juniors;
						price = not_for_juniors * price;
						nof_seat = not_for_juniors;
						system("pause");
					}
	
					else
					{
						cout <<"You are only allowed 10 tickets\n";
				
						SEAT_COUNT = SEAT_COUNT - 10;						
						JUNIORS = JUNIORS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * price;
						nof_seat = 10;
						system("pause");				
					}break;			

				case 3:

					cout << "How many tickets do you want for adults?\n";
					cin >>not_for_adults;

					if(not_for_adults <= 10)
					{

						SEAT_COUNT = SEAT_COUNT - not_for_adults;						
						ADULTS = ADULTS + not_for_adults;
						Total_Sold = Total_Sold + not_for_adults;
						price = not_for_adults * price;
						nof_seat = not_for_adults;
						system("pause");
						
					}

					else
					{
						cout <<"You are only allowed 10 tickets\n";
				
						SEAT_COUNT = SEAT_COUNT - 10;						
						ADULTS = ADULTS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * price;
						nof_seat = 10;
						system("pause");						
					}break;					
	
			}


				disPrice = apply_discount(price, Gross_total);
				disp_purchase(option, nof_seat, disPrice);
				return Total_Sold;
				return TODDLERS;
				return JUNIORS;
				return ADULTS;
				return SEAT_COUNT; 
				return price;
				return nof_seat;
				
			}
		  
			if (Total_Sold >= MAX_SEAT_COUNT)
		  	{
		  		system("CLS");
		  		disp_final_report(MAX_SEAT_COUNT, Total_Sold, TODDLERS, JUNIORS, ADULTS, Gross_total);
				system("pause");
		  		
		  	}
			
		}
		}
	}
  
	//open get_ticket_type()
  	
	int get_ticket_type(&option)
	{
		
				
		
			cout <<"Summerville SeaWorld Ticket Sales v1.02\n";
			cout <<"--------------------------------------\n";
  			cout <<"Enter the following details for ticket sales:\n";
  			cout <<"*********************************************************\n";
			cout << "Ticket Menu"<<endl;
	   		cout << "----------"<<endl;
	   		cout << "1. Toddlers"<<endl;
	   		cout << "2. Juniors"<<endl;
	   		cout << "3. Adults"<<endl;
	   		cout << "4. Clear Screen"<<endl;
	   		cout << "5. Quit"<<endl;
			cin >> option;
			system("pause");
	   
				   		
			switch(option)
			{
				case 1: 
					return option;
					break;
				case 2:
					return option;
					break;
				case 3: 	
					return option;
					break;
				case 4:
					cout << "Enter \'q'\ to quit or any other charachter to continue: ";
 					cin >> cont;
					return cont;
					break;
				default:	
					cout << "Invalid selection\n";
					
			}
	   						 
		
	 	
	}//close get_ticket_type()

  	double find_ticket_price(&option, &price)
	{
						
		switch(option)
		{
			case 1: 
				price = 0.0;
				break;
			case 2:
				price = 7.50;
				break;
			case 3:
				price = 11.50;
				break;
			default:
				cout << "Invalid selection."
				
		}

		return price;
			      
	}//close find_ticket_price

   	double apply_discount(&price, &Gross_total)
	{
	 	
		double toPrice = price;
		double disPrice = 0.0;
		double discount = 0.0;
		char coupon;
		
		cout << "Do you have a discount coupon? 1 for yes, 2 for no "<<endl;
	 	cin >> coupon;
	 
		switch(coupon)
		{
			case 1:
				discount= price * 0.25;
				disPrice = toPrice - discount;
				Gross_total = Gross_total + disPrice;
				break;
			case 2:
				disPrice = 0.0
				Gross_total = Gross_total + price;
				break;
	       	}
		
		return Gross_total;
		return disPrice;
		return toPrice;

		
	 }//close apply_discount
      
	void disp_purchase(&option, &nof_seat, &disPrice)
	{
		
		

		cout <<"\nWelcome to Summerville SeaWorld"<<endl;
		cout << "------------------------------------------"<<endl;
		cout << "Ticket Details:"<<endl;
		cout << "---------------"<<endl;
	 
		switch(option)
		{
			case 1:
				cout << "Toddler Tickets"<<endl;
				break;
			case 2:
				cout << "Junior Tickets"<<endl;
				break;
			case 3:
				cout << "Adult Tickets"<<endl;
				break;
		}
		
		cout <<"The number of tickets purchased: "<<nof_seat<<;
	 
		if(disPrice = 0.0 )
		{
			cout << "\nYour total amount is $" <<disPrice<<endl;
		}
	 	else
		{
			cout << "\nYour total amount after discount is $" <<disPrice<<endl;
		}
	 	
		cout << "------------------------------------------\n";
	 	
	}// close disp_purchase

   	void disp_final_report(&MAX_SEAT_COUNT, &Total_Sold, &TODDLERS, &JUNIORS, &ADULTS, &Gross_total)
	{
		
				
		time_t now = time(0);
		tm* localtm = localtime(&now);

		cout <<"******************************************************\n";
		cout << "TICKET SALES REPORT FOR DATE:"<<  asctime(localtm)<<;
		cout <<"------------------------------------------------------\n";
		cout << "SEAT CAPACITY\tLEFT\t\tTOTAL SOLD\n";
		cout <<"---------------------------------------\n";
		cout <<MAX_SEAT_COUNT<<"\t\t"<<(MAX_SEAT_COUNT-Total_Sold)<<"\t\t"<<Total_Sold<<"\n";
		cout <<"---------------------------------------\n";
		cout << "TODDLERS\tJUNIORS\t\tADULTS \n";
		cout <<"---------------------------------------\n";
		cout <<  TODDLERS<<"\t\t"<<JUNIORS<<"\t\t"<<ADULTS<<"\n";
		cout <<"---------------------------------------\n";
		cout << "GROSS FOR TODAY: $"<<Gross_total<<"\n";
		cout <<"***************************************\n";
		cout << "Press any key to exit..."<<endl;
	
	
	 }//close disp_final_report 
Apr 25, 2013 at 6:45pm
I'm having a problem with the data types I'm trying to pass, but I can't figure it out.

It would help if you could at least try to describe the problem. As it is, that's pretty vague.
Last edited on Apr 25, 2013 at 6:46pm
Apr 25, 2013 at 7:06pm
These are the errors I get:

prog.cpp:39:27: error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int*’
prog.cpp:7:7: error: in passing argument 1 of ‘int get_ticket_type(int&)’
prog.cpp:51:37: error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int*’
prog.cpp:8:10: error: in passing argument 1 of ‘double find_ticket_price(int&, double&)’
prog.cpp:159:91: error: invalid initialization of reference of type ‘double&’ from expression of type ‘int’
prog.cpp:11:8: error: in passing argument 2 of ‘void disp_final_report(int&, double&, int&, int&, int&, double&)’
prog.cpp: At global scope:
prog.cpp:170:21: error: ‘int get_ticket_type’ redeclared as different kind of symbol
prog.cpp:7:7: error: previous declaration of ‘int get_ticket_type(int&)’
prog.cpp:170:23: error: ‘option’ was not declared in this scope
Apr 25, 2013 at 7:46pm
You can only return one thing from a function. So this is wrong.
155
156
157
158
159
160
161
return Total_Sold;
return TODDLERS;
return JUNIORS;
return ADULTS;
return SEAT_COUNT; 
return price;
return nof_seat;


your function headers are wrong. For example this double apply_discount(&price, &Gross_total) should be double apply_discount(double &price, double &Gross_total)


when you pass an argument by referance you don't need the & in the function call. So this is wrong find_ticket_price(&option, &price); should be find_ticket_price(option, price);
Apr 25, 2013 at 8:14pm
Ok - I've got it running now - thanks for your help with that! Now my problem is the gross_total. It's returning 0 - any idea on how I can fix that? All of the other calculations are correct.
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
/************************************************************/
/* FILENAME : program6SolutionLangdon.cpp                   */
/* PROGRAMMER: Amy Langdon                                  */
/* PURPOSE : To track ticket sales for Summerville SeaWorld */
/************************************************************/



#include <iostream>
#include<time.h>
using namespace std;

	
		//function prototypes
		int get_ticket_type(int &option);
		double find_ticket_price(int &option, double &price);
		double apply_discount(double &price, double &Gross_total);
		void disp_purchase(int &option, int &nof_seat, double &disPrice);
		void disp_final_report(int &MAX_SEAT_COUNT, int &Total_Sold, int &TODDLERS, int &JUNIORS, int &ADULTS, double &Gross_total);


	int main()
	{
		
		int SEAT_COUNT = 0;
		int MAX_SEAT_COUNT = 16;
		int option = 1;
		int Total_Sold = 0;
		int not_for_toddlers;
		int not_for_juniors;
		int not_for_adults;
		int TODDLERS = 0;
		int JUNIORS = 0;
		int ADULTS = 0;	
		double Gross_total = 0.0;
		int nof_seat = 0;
		double price = 0.0;
		double disPrice = 0.0;
		char cont = '\0';
 		const char SENTINEL = 'q';
		
		while (cont != SENTINEL)
		{
		
		while (option != 5 && SEAT_COUNT < MAX_SEAT_COUNT)
		{
			get_ticket_type(option);

			if(option==5)
			{	
				break;
			}
				
			if(option==4)
			{
				system("CLS");
			}
		
			find_ticket_price(option, price);
		
			if(option > 1 && option < 4)
			{
				
				switch(option)
				{
				case 1:
					cout << "How many tickets do you want for toddlers?\n";
					cin >> not_for_toddlers;
			
					if(not_for_toddlers <= 10)
					{
						SEAT_COUNT = SEAT_COUNT - not_for_toddlers;
						TODDLERS = TODDLERS + not_for_toddlers;
						Total_Sold = Total_Sold + not_for_toddlers;
						price = not_for_toddlers * price;
						nof_seat = not_for_toddlers;
						system("pause");
						
					}
	
					else
					{	
						cout <<"You are only allowed 10 tickets\n";

						SEAT_COUNT = SEAT_COUNT - 10;
						TODDLERS = TODDLERS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * price;
						nof_seat = 10;
						system("pause");
						
					}break;

				case 2:
					cout << "How many tickets do you want for juniors?\n";
					cin >>not_for_juniors;

					if(not_for_juniors <= 10)
					{
						SEAT_COUNT = SEAT_COUNT - not_for_juniors;
						JUNIORS = JUNIORS +  not_for_juniors;
						Total_Sold = Total_Sold + not_for_juniors;
						price = not_for_juniors * price;
						nof_seat = not_for_juniors;
						system("pause");
					}
	
					else
					{
						cout <<"You are only allowed 10 tickets\n";
				
						SEAT_COUNT = SEAT_COUNT - 10;						
						JUNIORS = JUNIORS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * price;
						nof_seat = 10;
						system("pause");				
					}break;			

				case 3:

					cout << "How many tickets do you want for adults?\n";
					cin >>not_for_adults;

					if(not_for_adults <= 10)
					{

						SEAT_COUNT = SEAT_COUNT - not_for_adults;						
						ADULTS = ADULTS + not_for_adults;
						Total_Sold = Total_Sold + not_for_adults;
						price = not_for_adults * price;
						nof_seat = not_for_adults;
						system("pause");
						
					}

					else
					{
						cout <<"You are only allowed 10 tickets\n";
				
						SEAT_COUNT = SEAT_COUNT - 10;						
						ADULTS = ADULTS + 10;
						Total_Sold = Total_Sold + 10;
						price = 10 * price;
						nof_seat = 10;
						system("pause");						
					}break;					
	
			}


				disPrice = apply_discount(price, Gross_total);
				disp_purchase(option, nof_seat, disPrice);
				
				
			}
		  
			if (Total_Sold >= MAX_SEAT_COUNT)
		  	{
		  		system("CLS");
		  		disp_final_report(MAX_SEAT_COUNT, Total_Sold, TODDLERS, JUNIORS, ADULTS, Gross_total);
				system("pause");
		  		
		  	}
			
		}
		}
	}
  
	//open get_ticket_type()
  	
	int get_ticket_type(int &option)
	{
		
			char cont;	
		
			cout <<"Summerville SeaWorld Ticket Sales v1.02\n";
			cout <<"--------------------------------------\n";
  			cout <<"Enter the following details for ticket sales:\n";
  			cout <<"*********************************************************\n";
			cout << "Ticket Menu"<<endl;
	   		cout << "----------"<<endl;
	   		cout << "1. Toddlers"<<endl;
	   		cout << "2. Juniors"<<endl;
	   		cout << "3. Adults"<<endl;
	   		cout << "4. Clear Screen"<<endl;
	   		cout << "5. Quit"<<endl;
			cin >> option;
			system("pause");
	   
				   		
			switch(option)
			{
				case 1: 
					return option;
					break;
				case 2:
					return option;
					break;
				case 3: 	
					return option;
					break;
				case 4:
					cout << "Enter \'q'\ to quit or any other charachter to continue: ";
 					cin >> cont;
					return cont;
					break;
				default:	
					cout << "Invalid selection\n";
					
			}
	   						 
		
	 	
	}//close get_ticket_type()

  	double find_ticket_price(int &option, double &price)
	{
						
		switch(option)
		{
			case 1: 
				price = 0.0;
				break;
			case 2:
				price = 7.50;
				break;
			case 3:
				price = 11.50;
				break;
			default:
				cout << "Invalid selection.";
				
		}

		return price;
			      
	}//close find_ticket_price

   	double apply_discount(double &price, double &Gross_total)
	{
	 	
		double toPrice = price;
		double disPrice = 0.0;
		double discount = 0.0;
		char coupon;
		
		cout << "Do you have a discount coupon? 1 for yes, 2 for no "<<endl;
	 	cin >> coupon;
	 
		switch(coupon)
		{
			case 1:
				discount= price * 0.25;
				disPrice = toPrice - discount;
				Gross_total = Gross_total + disPrice;
				return Gross_total;
				return disPrice;
				break;
			case 2:
				disPrice = 0.0;
				Gross_total = Gross_total + price;
				return Gross_total;
				return disPrice;
				break;
	       	}
		
		return toPrice;

		
	 }//close apply_discount
      
	void disp_purchase(int &option, int &nof_seat, double &disPrice)
	{
		
		

		cout <<"\nWelcome to Summerville SeaWorld"<<endl;
		cout << "------------------------------------------"<<endl;
		cout << "Ticket Details:"<<endl;
		cout << "---------------"<<endl;
	 
		switch(option)
		{
			case 1:
				cout << "Toddler Tickets"<<endl;
				break;
			case 2:
				cout << "Junior Tickets"<<endl;
				break;
			case 3:
				cout << "Adult Tickets"<<endl;
				break;
		}
		
		cout <<"The number of tickets purchased: "<<nof_seat<<"\n";
	 
		if(disPrice == 0.0)
		{
			cout << "\nYour total amount is $" <<disPrice<<endl;
		}
	 	else
		{
			cout << "\nYour total amount after discount is $" <<disPrice<<endl;
		}
	 	
		cout << "------------------------------------------\n";
	 	
	}// close disp_purchase

   	void disp_final_report(int &MAX_SEAT_COUNT, int &Total_Sold, int &TODDLERS, int &JUNIORS, int &ADULTS, double &Gross_total)
	{
		
				
		time_t now = time(0);
		tm* localtm = localtime(&now);

		cout <<"******************************************************\n";
		cout << "TICKET SALES REPORT FOR DATE:"<<asctime(localtm)<<"\n";
		cout <<"------------------------------------------------------\n";
		cout << "SEAT CAPACITY\tLEFT\t\tTOTAL SOLD\n";
		cout <<"---------------------------------------\n";
		cout <<MAX_SEAT_COUNT<<"\t\t"<<(MAX_SEAT_COUNT-Total_Sold)<<"\t\t"<<Total_Sold<<"\n";
		cout <<"---------------------------------------\n";
		cout << "TODDLERS\tJUNIORS\t\tADULTS \n";
		cout <<"---------------------------------------\n";
		cout <<  TODDLERS<<"\t\t"<<JUNIORS<<"\t\t"<<ADULTS<<"\n";
		cout <<"---------------------------------------\n";
		cout << "GROSS FOR TODAY: $"<<Gross_total<<"\n";
		cout <<"***************************************\n";
		cout << "Press any key to exit..."<<endl;
	
	
	 }//close disp_final_report 
Topic archived. No new replies allowed.