C++ Program that calculates commute cost.. how do I fix this error? details below.

Sep 15, 2013 at 8:31pm
"if you run the program you will notice that it ignores the amount of daily tolls and parkingfees. This should be quite simple, multiplying x times parkingfee etc. How would I set this up properly with the way my application is coded so that it will perform this action. Thank you. Forgot to mention, if I wanted to use a Dollar sign, what operator would be need used so that it would be displayed to the left of the output.

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
#include <iostream> //allows I/0
using namespace std; //uses name from std namespace


int main() //main begins program execution
{
double milesperday= 0; //first integer
double costpergallon = 0; //second integer
double avmilespergallon= 0; //etc.. average miles per gallon
double parkingfeedaily= 0; //....daily parking fee
double dailytolls = 0; //...daily tolls price daily
double costperday = 0; //..output the total cost






cout << "a) Total Miles driven per day."; //prompt for data
cin  >> milesperday; // read integers from user
cout << "b) Cost per gallon of gasoline."; //prompt for data
cin >> costpergallon ; //read integers from user
cout << "c) Average Miles per gallon."; //prompt for data
cin >> avmilespergallon ; //read integer from user
cout << "d) Parking fees per day."; //prompt user for data
cin >> parkingfeedaily ; //read integer from user
cout << "e) Tolls per day."; //prompt for data
cin >> dailytolls ; //read integer from user
 
dailytolls =1.25;
 parkingfeedaily= 1.26;

 costperday= dailytolls+parkingfeedaily+(milesperday/avmilespergallon)*costpergallon; 
cout << "Cost per day of driving to work="<<costperday<<endl;






return 0;
}
Last edited on Sep 15, 2013 at 8:35pm
Sep 16, 2013 at 2:37am
if you run the program you will notice that it ignores the amount of daily tolls and parkingfees


Your're inputting those values at lines 26 and 28, but then you're overwriting those values at lines 30 and 31.
Topic archived. No new replies allowed.