#include <iostream> using namespace std; #define LPG (0.264179) double MilesPerG
ID: 3644621 • Letter: #
Question
#include <iostream>using namespace std;
#define LPG (0.264179)
double MilesPerGallon(double milesf, double litersf)
{
return (milesf*LPG/litersf);
}
void main()
{
double fliters, fmiles, sliters, smiles, fmpg, smpg;
char continue;
do
{
cout<<"Enter miles traveled by first car"<<endl;
cin>>fmiles;
cout<<"Enter in liters gasoline consumed"<<endl;
cin>>fliters;
cout<<"Enter miles traveled by second car"<<endl;
cin>>smiles;
cout<<"Enter in liters gasoline consumed"<<endl;
cin>>sliters;
if (fliters == 0 || sliters == 0)
cout<<" Invalid input";
else
{
fmpg = MilesPerGallon (fmiles, fliters);
smpg = MilesPerGallon (smiles, sliters);
cout<<"Miles per gallon "<<fmpg<<endl;
cout<<"Miles per gallon "<<smpg<<endl;
}
if (fmpg == smpg)
{
cout<<"Both cars are best"<<endl;
}
else if (fmpg > smpg)
{
cout<<"First car is best"<<endl;
}
else
cout<<"Second car is best"<<endl;
cout<<If you want to repeat calculations
press 'Y' or 'y'"<<endl;
cin>>Continue;
}
I can't get this program to run and I am not sure what I am doing wrong. Will someone please help me and let me know what is wrong because I can't figure it out.
Explanation / Answer
#define LPG (0.264179) ; -- Semi colun missing above;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.