i cant figure out why this code wont work

OK so i'm in a C++ class and for this lab i have to make a little store program, i got most of it working so far but when i try to make the
total == (vale of item) * (quantity) + total
nothing happens, the screen clears and the loops puts the updated menu screen back up but the total value is unchanged.
sorry if this is not the right place to post or whatever, this is literally the first time iv posted in any forum.
i also tried total == total + (value of item) * (quantity) but neither one worked for me
(first one is line 74 btw)

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
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <windows.h>


using namespace std;

int main()
{

/////DECLARE VALUES
    bool cashout=true;
    int total(0);
    int coins(50);
    int hatValue(2);
    int whipValue(5);
    int knifeValue(10);
    int revolverValue(25);
    int ammoValue(1);
    int torchValue(8);
    int compassValue(3);
    int tntValue(4);
    int quant;
    int payment;
    string buy;
    string input;

    cout << " Hello, and welcome to the adventurers store!" << endl
         << " One stop shopping for any adventure!" << endl << endl
         << " I read about your adventure in that pyrimid" << endl
         << " and I see your pockets are brimming with" << endl
         << " goodies from that treasure room!" << endl << endl
         << " Please, look over the list of our items" << endl << endl
         << " If you like what you see just name the item," << endl
         << " and i'll put it in your basket." << endl << endl
         << " and when your all done just say when you want to" << endl
         << " \"cash out\" and we can discuss payment" << endl << endl;

     system("pause");
     system("CLS");

while (cashout)
{
    cout << endl
         << "-------------In Stock---------------" << endl
         << " adventurers hat........2 Gold coins" << endl
         << " whip...................5 Gold coins" << endl
         << " knife.................10 gold coins" << endl
         << " revolver..............25 gold coins" << endl
         << " ammo box...12 rounds per gold  coin" << endl
         << " torch..................8 gold coins" << endl
         << " compass................3 gold coins" << endl
         << " TnT....................4 gold coins" << endl
         << "------------------------------------" << endl << endl

         << "-------------Coin Purse-------------" << endl
         << " gold coins......................." << coins << endl
         << "------------------------------------" << endl << endl

         << "-------------Basket-----------------" << endl
         << "total.................." << total << " Gold coins" << endl
         << "------------------------------------" << endl;

    cin >> buy;

    if (buy == "adventurers hat" || buy == "Adventurer Hat" || buy == "hat" || buy == "Hat" || buy == "Adventurers hat")
    {
        cout << " Ahh yes, whats an adventurer without a hat?" << endl
             << " Well then how many will you need?" << endl;
        cin >> quant;
        cout << endl << " Ok then! I'll just put this in your basket.";
        total == hatValue * quant + total;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "whip" || buy == "Whip")
    {
        cout << " Never know when a whip will come in handy" << endl
             << " Ok, how many?" << endl;
        cin >> quant;
        cout << endl << " Alright, off it goes into your basket.";
        total == total + quant * whipValue;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "Knife" || buy == "Knife")
    {
        cout << " Yes, a good knife can be a lifesaver." << endl
             << " Well then how many will you be wanting?" << endl;
        cin >> quant;
        cout << endl << " OK.";
        total == total + quant * knifeValue;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "revolver" || buy == "Revolver")
    {
        cout << " Heh, you never know what you might come across " << endl
             << " on a perilous adventure." << endl
             << " And how many of these?" << endl;
        cin >> quant;
        cout << endl << " ok, ill just place this in your basket.";
        total == total + quant * revolverValue;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "ammo box" || buy == "Ammo Box" || buy == "ammo" || buy == "Ammo" || buy == "Ammo box")
    {
        cout << " whats a gun without ammo right?" << endl
             << " How many boxes did you want?" << endl;
        cin >> quant;
        cout << endl << " ok ill just drop this in your basket.";
        total == total + quant * ammoValue;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "Torch" || buy == "torch")
    {
        cout << " Ah yes a torch, you can explore if you cant see." << endl
             << " How many torches?" << endl;
        cin >> quant;
        cout << endl << " M'kay putting this in your basket now.";
        total == total + quant * torchValue;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "compass" || buy == "Compass")
    {
        cout << " im suprised an adventurer of your calibur" << endl
             << " doesnt have one of these already." << endl
             << " how may of these?" << endl;
        cin >> quant;
        cout << endl << " alright, into the basket it goes.";
        total == total + quant * compassValue;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "TnT" || buy == "tnt" || buy == "TNT" || buy == "Tnt")
    {
        cout << " Not too many uses for a stick of tnt, but you dont" << endl
             << " want to be caught without it when you do need it." << endl
             << " how may of these?" << endl;
        cin >> quant;
        cout << endl << " ok ill just put this in your basket..gently.";
        total == total + quant * tntValue;
        Sleep(2500);
        system("CLS");
    }
    if (buy == "Cash Out" || buy == "Cash out" || buy == "cash out" || buy == "Cashout")
    {
        cashout++;
    }
    else
    {
        system("CLS");
    }
}
    
    if (total != 0)
    {
       cout << "Ok then, your total is " << total ".";
       cin >> payment
        if (payment > total)
        {
           
        }
        if (payment == total)
        {
            
        }
        if (payment > total)
    }
    else
    {
        
    }
    return 0;
}
Last edited on
You are confusing operator== and operator=. You need to use a single equals sign in order to asign values, like the ones you want to assign to the variable 'total'. Inside IF statements, however, you use two equals signs in order to test equality.
omg lol.. i figured it was somthing simple.
thx a ton!
Topic archived. No new replies allowed.