C++ Total Price Program

I would like to make a program for calculating the total price of a game station, and a game. I made a program like this for just the price of a game in class, but I want to make one that does the game system as well. Any help would be appreciated.
What have you written so far? What are you having trouble with?
This is the code of what I did in class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <string>
using namespace std;
int main()
{
//declare variables
string gameName;
double gameCost, taxRate, totalCost, finalCost;
//get user input
cout<<"What game would you like to purchase?"<<endl;
cin>>gameName;
cout<<"what is the cost of the game? (do not include $)"<<endl;
cin>>gameCost;
cout<<"What is the tax rate in your state? (do not include $)"<<endl;
cin>>taxRate;
//calculate total cost
totalCost=gameCost*(1+taxRate/100);
finalCost=((int)(totalCost*100+0.5))/100.0;
cout<<"Your total for the game "<<gameName<<" is $"<<finalCost<<endl;

return 0;

}


I just need to know how to add the price of the console.

EDIT: I edited the code, but I am unable to compile and run it at home, so can some one please try it for me and tell me if it works?

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
#include <iostream>
#include <string>
using namespace std;
int main()
{
//declare variables
string gameName;
double consoleName, consoleCost, gameCost, taxRate, totalCost, finalCost;
//get user input
cout<<"What game console would you like to purchase?"<<endl;
cin>>consoleName;
cout<<"What is the cost of the console?"<<endl;
cin>>consoleCost;
cout<<"What game would you like to purchase?"<<endl;
cin>>gameName;
cout<<"what is the cost of the game? (do not include $)"<<endl;
cin>>gameCost;
cout<<"What is the tax rate in your state? (do not include $)"<<endl;
cin>>taxRate;
//calculate total cost
totalCost=consoleCost+gameCost*(1+taxRate/100);
finalCost=((int)(totalCost*100+0.5))/100.0;
cout<<"Your total for the game and console "<<gameName<<" is $"<<finalCost<<endl;

return 0;

}
Last edited on
closed account (48T7M4Gy)
It compiles and runs. But why can't you just press the gear wheel at the top right corner of your message :-)
@remort, I did not know about that gear, thank you for that. I tried the gear, but I can only do the first input, the others don't work.
I edited the code, where I saw an error, and ran it, but now it still only runs the first half of the input. Please help.
I fixed it, thanks for the very little help.
maybe you should try reading about
Switch, if-else, or conditionals.
There are a lot of it.

Ex:
1
2
3
4
5
6
7
8
9
10
11
12
13
switch (gameName)
{
     case 'DotA':
         {
               gameCost = 1000;     // gamecost in dollars..\
               break;
          }
     case 'Barbie and the Swan Lake':
         {
               gameCost = 1;
               break;
         }
}


or try reading about
enum types {};
Topic archived. No new replies allowed.