Calculating MPG using simple C++

I have to create a program calculating a car's gas mileage. The program should ask the user to enter the number of gallons of gas the car can hold, and the number of miles it can be driven on a full tank. It should then display the number of miles that may be driven per gallon of gas.

This is what I have so far. It seems okay but I could be completely wrong, this is my fist ever in a class creating programs so I am completely new to this.

#include <iostream>
using namespace std;
int main()
{
double capacity, miles, average
cout << "enter he number of gallons a tank can hold ";
cin >> capacity;
cout << "enter the number of miles driven on a full tank ";
cin >> miles;
average = miles/capacity
// calculate the dividend of the two numbers
// display the MPG
cout << the car’s mpg is: " << average << endl;
system("PAUSE");
return 0;

PLEASE HELLLP! :)
Hi,
Firstly :
double capacity, miles, average
Missing a semi-colon ( ; ) at the end of the statement.

==>
double capacity, miles, average;
Secondly :
average = miles/capacity
Missing a semi-colon ( ; ) at the end of the statement.

==>
average = miles / capacity;
Thirdly :
cout << the car’s mpg is: " << average << endl;
Missing a quotation mark (") at the beginning of the string.

==>
cout << "the car’s mpg is: " << average << endl;
Okay thank you!
Should I have put // display the mpg after cout << the car's mpg is: "? @5a8Ym39o6
Last edited on
> Should I have put "// display the mpg" after cout << "the car's mpg is: "?
You can put this comment everywhere, but do not let its green color cover this line cout << "the car's mpg is: ";
Okay sweet.
Good to hear :)
Thank so much for your help :)
Topic archived. No new replies allowed.