You will write a program to determine the gas mileage use on atrip, given the mi
ID: 3608333 • Letter: Y
Question
You will write a program to determine the gas mileage use on atrip, given the miles driven and the gallons used. Theprogram should then calculate and print out the miles pergallon. Lastly, the program will print a comment based on theMPG results.
Specification
double milesPerGallon(int m, intg);
mpg >= 30 Tree hugging is fun.
30 > mpg >= 22 You've seen InconvenientTruth.
22 > mpg >= 15 What's Global Warming??
15 > mpg I think you just ran over a squirrel with your Hummer.
Explanation / Answer
please rate - thanks #include #include double milesPerGallon(int m, int g); int main() {int miles, gallons; double MPG; printf("Enter the miles driven: "); scanf("%d",&miles); printf("Enter the amount of gallons used: "); scanf("%d",&gallons); MPG=milesPerGallon(miles,gallons); printf("Your MPG is: %lf ",MPG); if(MPG>=30) printf("Tree hugging is fun. "); else if(MPG>=22) printf("You've seen InconvenientTruth. "); else if(MPG>=15) printf("What'sGlobal Warming?? "); else printf("I thinkyou just ran over a squirrel with your Hummer. "); getch(); return 0; } double milesPerGallon(int m, int g) {return((double)m/g); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.