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.

/* 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, answ;
    double mug, teeshirt, pen, tot_mon, curr_cash, mon_spent;

    cout << "You have 30 dollars to spend.\n";
    do
    {
        cout << endl;
    cout << "What do you want to buy today?\n";
     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 \n" << endl;
            mug = 2.50;
            curr_cash = tot_mon - mug;
            cout << " You have " << curr_cash << " remaining \n " << 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 \n " << 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 \n " << 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\n" << endl;
            curr_cash = tot_mon - mon_spent;
        }
        else
        {
            cout << " Would you like anothe purchase, please choose another letter.\n" << endl;

                            }
        } while ( curr_cash <= 0);

        cout << "Thank you for shopping.\n";
    return 0;
 }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

#include <Windows.h>
#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    char	symb;

    double	mug		= 2.50f,
		teeshirt	= 9.50f,
		pen		= 0.75f,
		tot_mon	= 30.0f;


    cout << "You have 30 dollars to spend.\n";
	
    do
    {
        cout << endl;
   		cout << "What do you want to buy today?\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;

            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 \n" << endl;
            tot_mon -= mug; // minus equal total money
            cout << " You have " << tot_mon << " remaining \n " << endl;
            break;

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

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

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

            default:
            cout << "Input error. Select again" << endl;
        }
        if ( tot_mon == 0.0f ) // == not =
            cout << "You need more cash, you dont have enough\n" << endl;
        else
            cout << " Would you like anothe purchase, please choose another letter.\n" << endl;

        } while ( tot_mon >= 0.0f ); // Bigger than not smaller than
      
        cout << "Thank you for shopping.\n";

	return NULL;
}

I recomend doing the money check before hand, and if you want to add a Item count then simply multiply the money amount by it.

i have never used and i dont believe my teacher wants us to use these

#include <Windows.h> or #include <conio.h>

is there away to create this program using this format

#include<iostream>
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;

yes those aren't needed ( you can erase them )
They just got mixed in when I pasted your code into my previous project.

now these errors r coming up

error: expected `,' or `;' before "tot_mon"|
error: `curr_cash' was not declared in this scope|
error: `curr_cash' was not declared in this scope|
error: `mon_spent' was not declared in this scope|
error: `curr_cash' was not declared in this scope|

yes i got it. but do you know why i had to do that? i just dont want the answer i want to actually understand why so i wont be lost when i have to do it on a test?
you are very smart and i would like ur help

This article has been dead for over six months. Start a new discussion instead.