A liter is 0.264179 gallons. Write a program that will read in the number of lit
ID: 3761758 • Letter: A
Question
A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline consumed by the user’s car and the number of miles traveled by the car and will then output the number of miles per gallon the car delivered. Your program should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the number of miles per gallon. Your program should use a globally defined constant for the number of liters per gallon.
The simplest way to write this in c++ programming
Explanation / Answer
#include<iostream>
#include<limits.h>
using namespace std;
double milesPerGallon(double petrol,double miles ){
double gallons = 0.264179*petrol;
return miles/gallons;
}
int main(){
cout<<milesPerGallon(5,10)<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.