debugging
Apr 24, 2013 at 2:58am UTC
I can't get this to run for anything. Any ideas where I went wrong?
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
#include <stdio.h>
#include <iostream>
#include <conio.h>
#include <time.h>
#include <string>
using namespace std;
int main()
{
int SEAT_COUNT;
int MAX_SEAT_COUNT = 25;
int option;
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 price;
double discount;
double Gross_total = 0.0;
char tmpbuf[128];
char coupon;
SEAT_COUNT = MAX_SEAT_COUNT;
cout << "Summerville SeaWorld Ticket Sales v1.01\n" ;
while (SEAT_COUNT >=0 )
{
cout << "\nSummerville SeaWorld Ticket Menu\n" ;
cout << "----------\n" ;
cout << "1. Toddlers\n" ;
cout << "2. Juniors\n" ;
cout << "3. Adults\n" ;
cout << "4. Quit\n" ;
cout << "Enter your option " ;
cin >> option;
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;
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout <<"-------------------------------\n" ;
cout <<"\nThe total for these tickets is $0.00\n" ;
cout << "------------------------------------------\n" ;
TODDLERS = TODDLERS + not_for_toddlers;
Total_Sold = Total_Sold + not_for_toddlers;
system("pause" );
break ;
}
else
{
cout <<"You are only allowed 10 tickets\n" ;
SEAT_COUNT = SEAT_COUNT - 10;
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout <<"-------------------------------\n" ;
cout <<"\nThe total for these tickets is $0.00\n" ;
cout << "------------------------------------------\n" ;
TODDLERS = TODDLERS + 10;
Total_Sold = Total_Sold + 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;
price = not_for_juniors * 7.50;
JUNIORS = JUNIORS + not_for_juniors;
Total_Sold = Total_Sold + not_for_juniors;
cout << "\nDo you have a discount coupon? (y/n) \n" ;
cin >> coupon;
if ('y' == coupon)
{
discount = price * 0.25;
price = price - discount;
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "Your total discount is $" <<discount<<"\n" ;
cout << "\nYour total amount after the discount is $" <<price<<"\n" ;
cout << "------------------------------------------\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
else
{
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "\nYour total amount is $" <<price;
cout << "------------------------------------------\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
}
else
{
cout <<"You are only allowed 10 tickets\n" ;
SEAT_COUNT = SEAT_COUNT - 10;
price = 10 * 7.50;
JUNIORS = JUNIORS + 10;
Total_Sold = Total_Sold + 10;
cout << "\nDo you have a discount coupon? (y/n) \n" ;
cin >> coupon;
if ('y' == coupon)
{
discount = price * 0.25;
price = price - discount;
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "Your total discount is $" <<discount<<"\n" ;
cout << "\nYour total amount after the discount is $" <<price<<"\n" ;
cout << "------------------------------------------\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
else
{
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "\nYour total amount is $" <<price;
cout << "------------------------------------------\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
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;
price = not_for_adults * 11.50;
ADULTS = ADULTS + not_for_adults;
Total_Sold = Total_Sold + not_for_adults;
cout << "Do you have a discount coupon? (y/n) \n" ;
cin >> coupon;
if ('y' ==coupon)
{
discount= price * 0.25;
price = price - discount;
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "Your total discount is $" <<discount<<"\n" ;
cout << "\nYour total amount after the discount is $" <<price<<"\n" ;
cout << "------------------------------------------\n\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
else
{
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "Your total amount is $" <<price<<"\n" ;
cout << "------------------------------------------\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
}
else
{
cout <<"You are only allowed 10 tickets\n" ;
SEAT_COUNT = SEAT_COUNT - 10;
price = 10 * 11.50;
ADULTS = ADULTS + 10;
Total_Sold = Total_Sold + 10;
cout << "\nDo you have a discount coupon? (y/n) \n" ;
cin >> coupon;
if ('y' == coupon)
{
discount = price * 0.25;
price = price - discount;
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "Your total discount is $" <<discount<<"\n" ;
cout << "\nYour total amount after the discount is $" <<price<<"\n" ;
cout << "------------------------------------------\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
else
{
cout.precision( 2 );
cout <<"\nWelcome to Summerville SeaWorld\n" ;
cout << "------------------------------------------\n" ;
cout << "\nYour total amount is $" <<price<<"\n" ;
cout << "------------------------------------------\n" ;
Gross_total = Gross_total + price;
system("pause" );
break ;
}
break ;
}
case 4:
cout << "Quit" ;
return 0;
default :
cout << "Please enter a valid option\n" ;
}
}
time_t now;
time(&now);
//printf("It's %.24s.\n", ctime_s(&now));
cout <<"***************************************\n" ;
cout << "TICKET SALES REPORT FOR DATE:" << _strdate_s(tmpbuf)<<"\n" ;
cout <<"---------------------------------------\n" ;
cout << "SEAT CAPACITY \t EXTRA \t TOTAL SOLD\n" ;
cout <<"---------------------------------------\n" ;
cout <<MAX_SEAT_COUNT<<"\t\t" <<(Total_Sold-MAX_SEAT_COUNT)<<"\t\t" <<Total_Sold<<"\n" ;
cout <<"---------------------------------------\n" ;
cout << "TODDLERS \tJUNIORS \tADULTS \n" ;
cout <<"---------------------------------------\n" ;
cout << TODDLERS<<"\t\t" <<JUNIORS<<"\t\t" <<ADULTS<<"\n" ;
cout <<"---------------------------------------\n" ;
cout << "GROSS FOR TODAY: $" <<Gross_total<<"\n" ;
cout <<"***************************************\n" ;
return 0;
}
Apr 24, 2013 at 5:12am UTC
What is supposed to be happening?
Apr 24, 2013 at 5:33am UTC
Post exact error here.
Apr 24, 2013 at 9:35am UTC
I don't get an error. It runs, but does none of the calculations. It is supposed to be accepting input for ticket amounts and then calculating the cost depending on if they have a coupon or not. It's also supposed to track sales of each type of ticket.
Topic archived. No new replies allowed.