Question: This is for C Programming: Complete the program by writing and testing the CalcMpg() function. #include double ConvKilometersToMiles(double numKm) { double milesPerKm = 0.621371; return
This is for C Programming:
Complete the program by writing and testing the CalcMpg() function.
#include
double ConvKilometersToMiles(double numKm) { double milesPerKm = 0.621371; return numKm * milesPerKm; } double ConvLitersToGallons(double numLiters) { double litersPerGal = 0.264172; return numLiters * litersPerGal; } double CalcMpg(double distMiles, double gasGallons) { printf("FIXME: Calculate MPG "); return 0.0; } int main(void) { double distKm; double distMiles; double gasLiters; double gasGal; double userMpg; printf("Enter kilometers driven: "); scanf("%lf", &distKm); printf("Enter liters of gas consumed: "); scanf("%lf", &gasLiters); distMiles = ConvKilometersToMiles(distKm); gasGal = ConvLitersToGallons(gasLiters); userMpg = CalcMpg(distMiles, gasGal); printf("Miles driven: %lf ", distMiles); printf("Gallons of gas: %lf ", gasGal); printf("Mileage: %lf mpg ", userMpg); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
