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.
#include <iostream>
#include <string>
usingnamespace 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?
#include <iostream>
#include <string>
usingnamespace 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;
}