Did i use the code tag correctly ? let me know?
Im trying to figure out how to error trap this program so if the user doesnt put in a valid response then a message will cum up and they will go back 2 the beginning until they do it correctly.
also i want to subtract the money they spend and tell them their remaining amount, also i want to keep track of the number of items they purchase.
when i do it all that comes up is a whole bunch of numbers.
can anyone help when you compile this program i want this format but the numbers arent right
can anyone help?
/* SIUE's bookstore is having aspecail sale on tiems embossed with the cougar logo. For a limited time, three items, mugs, teeshirts, and pens
are offered at a reduced rate with tax included to simplify the sales. Mugs are going for $2.50, teeshirts for $9.50 and pens for 75
cents. Coincidentally, your parents (or spouse, friend, coworker, or other person you know off-campus) just gave you $30.00 to buy SIUE
stuff for them.*/
#include<iostream>
using namespace std;
int main()
{
char symb;
int item_purch, numb_item_purch, quit;
double mug, teeshirt, pen, tot_mon, curr_cash, mon_spent;
cout << "What do you want to buy today?\n";
cout << "You have 30 dollars to spend.\n";
cout << " A) Mugs $2.50 " << endl;
cout << " B) teeshirt $9.50 " << endl;
cout << " C) Pens .75 cents " << endl;
cout << " D) Quit" << endl;
cout << " Enter your letter and press Return when finished" << endl;
cin >> symb;
switch (symb)
{
case 'A':;
case 'a':;
cout << " You have choosen A) mugs for $2.50 \n";
mug = 2.50;
cout << " You have " << curr_cash << " remaining \n ";
tot_mon = 30;
curr_cash = tot_mon - mug;
cout << " You have purchased " << numb_item_purch << " today \n ";
numb_item_purch = item_purch + 1;
break;
case 'B':;
case 'b':;
cout << " You have choosen B) teeshirt for $9.50 ";
teeshirt = 9.50;
break;
case 'C':;
case 'c':;
cout << " You have choosen C) Pens for .75 cents ";
pen = .75;
break;
case 'D':;
case 'd':;
cout << " You have choosen D) which means you want to Quit" << endl;
quit = 0;
break;
}
cin >> tot_mon;
curr_cash = tot_mon - mon_spent;
cin >> curr_cash;
cin >> mon_spent;
return 0;
}