Hello everyone, my question is that I have to write a program that calculates 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 calculate and display the number of miles per gallon the car gets.
Here is what I got from my understanding from the question.
#include <iostream>
usingnamespace std;
int main()
{
int galGas, miFulTnk, cal;
double average;
cout << "Please enter the number of gallons of gas your car can hold: ";
cin >> galGas;
cout << "Please enter the number of miles your car can be driven on a full tank: ";
cin >> miFulTnk;
cal = miFulTnk / galGas;
cout << "\nThe number of miles per gallon your car gets: " << cal << "." << endl << endl;
return 0;
}
Dput, my question is how can I get the number of miles per gallon that the car gets?
Should I divide the number of gallons of gas the car can hold with the number of miles it can be driven on a full tank?