I need help making the program find which car has the highest mpg and also when i run this program it only asks for the input for the first car not the second...
#include <iostream>
usingnamespace std;
double mpg_calc(double liters, int miles);
//Returns the mpg of car 1
double mpg_calc(double liters, double miles);
//Returns the mpg of car 2
constdouble GALLONS_PER_LITER = 0.264179; //conversion of how many gallons are in a liters, global
char ans;
int main() {
double liters, mpg1;
int miles;
do {
cout << " How many liters of gas are in your tank: ";// asks user for liters in tank
cin >> liters;
cout << " How many miles did you travel: "; // asks user for distance traveled
cin >> miles;
mpg1 = miles / (liters * GALLONS_PER_LITER); // function to find MPG
cout << " Your car's MPG is " << mpg1 << ".\n"; // outputing the users MPG
cout << " Would you like to run the program again?";//Allowing user the option to run again
cin >> ans;
}while (ans == 'y' || ans == 'Y');
system("pause");
return 0;
}
double mpg_calc(double liters, double miles) {
double rate, mpg2;
cout << " How many liters of gas are in your tank: ";
cin >> liters;
cout << " How many miles did you travel: ";
cin >> miles;
mpg2 = miles / (liters * GALLONS_PER_LITER);
return mpg2;
}