cost of vacation

I`m trying to develop a program that will determine the cost of a vacation by car to a variety of locations. The program should ask the user to enter the distance to the vacation destination, the price of a gallon of gas and the number of miles per gallon used by the vehicle. The program will calculate and display the cost of using the vehicle for the trip. I`m trying to have the output screen look like this

Distance ===================== > 1120
Cost per gallon ================= > 2.75
Miles per gallon ================ > 15.9

The cost of using this vehicle for the trip will be ======= > 193.75
so,what's the problem?
The best strategy is to try to write the program yourself and when and if you encounter problem ask for help. Not the other way around!
You should do something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;

int main() {
    float dist,cpg,mpg,result;
    cout<<"Distance:";
    cin>>dist;
    cout<<"Cost Per Gallon:";
    cin>>cpg;
    cout<<"Miles per Gallon:";
    cin>>mpg;
    cout<<"Calculating..."<<"\n";
    result=dist/mpg*cpg;
    cout<<"Cost:"<<result<<"\n";
    system("pause");
    }
Last edited on
Topic archived. No new replies allowed.