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
|