keep track of looping

How would i keep track of money spent? and items bought when i loop and how do i say i want multiple items meaning if i want to purchase more than one teeshirt or mug.


[code]/* 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
using namespace std;
int main()
{
char symb;
int item_purch, numb_item_purch, quit, answ;
double mug, teeshirt, pen, tot_mon, curr_cash, mon_spent;

cout << "You have 30 dollars to spend.
";
do
{
cout << endl;
cout << "What do you want to buy today?
";
tot_mon = 30;

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;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);


switch (symb)
{
case 'A':;
case 'a':;
cout << " You have choosen A) mugs for $2.50
" << endl;
mug = 2.50;
curr_cash = tot_mon - mug;
cout << " You have " << curr_cash << " remaining
" << endl;
tot_mon = 30;

break;
case 'B':;
case 'b':;
cout << " You have choosen B) teeshirt for $9.50 " << endl;
teeshirt = 9.50;
curr_cash = tot_mon - teeshirt;
cout << " You have " << curr_cash << " remaining
" << endl;
tot_mon = 30;
break;

case 'C':;
case 'c':;
cout << " You have choosen C) Pens for .75 cents " << endl;
pen = .75;
curr_cash = tot_mon - pen;
cout << " You have " << curr_cash << " remaining
" << endl;
tot_mon = 30;
break;

case 'D':;
case 'd':;
cout << " You have choosen D) which means you want to Quit" << endl;
quit = 0;
break;

default:
cout << "Input error. Select again" << endl;
}
if ( curr_cash = 0)
{
cout << "You need more cash, you dont have enough
" << endl;
curr_cash = tot_mon - mon_spent;
}
else
{
cout << " Would you like anothe purchase, please choose another letter.
" << endl;

}
} while ( curr_cash <= 0);

cout << "Thank you for shopping.
";

return 0;
}[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories