Alright guys, I was hoping someone could help me with this. Simple vending machine program. Only thing I'm missing is the grandTotal. I want to be able to tally up the price of the grand total at the very end of the program. For example, if I select 'A' for coffee and select 3 cups it'll cost $3 but then the program will ask if I want another beverage and if I select 'B' afterwards and select 2 cups for 'B' for example I want it to be able to add the total for the first selection to the second selection as well before I select 'E' to end the program and print out the grandTotal. So technically I would have $3 for the coffee/A and $1.50 for the tea/B, which would be $4.5 total. Where would I insert the code for that operation? I'm completely lost.
The easiest way to do this is to use your amount variable to keep track of the total. You can use the += operator to add to the amount every time another selection is made, for example: amount += 2.50 * cups;
Then, all you have to do is print out amount at the end of your program.