Question:

A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline comsumed by the user's car and the number of miles traveled by the car, and will then output the number of miles per gallons 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 numbers of liters per gallon.

I know it's not done but I want to know - Do I have the right idea or doing this all wrong?Code:#include <iostream> using namespace std; int main() { const double LIT_GAL = .264179; double miles; double gallons; double liters; char again; do { cout << "How many liters can your car hold?"; cin >> liters; cout << "How many miles can your car drive without refilling?"; cin >> miles; gallons = liters * LIT_GAL; cout << "Numbers of liters your car holds is " << liters << " liters.\n"; cout << "Number of miles your car drives without refilling tank " << miles << " miles.\n"; cout << "Press Y for yes or any key for no,\n"; cout << "then hit return.\n"; cin >> again; }while(again == 'y' || again == 'Y'); return 0; } double mpg (double miles, double gallons) { return(miles/gallons); }