/**************************************************************
*
* MILES PER GALLON CALCULATOR
* ________________________________________________________
* This program calculates the car's gas mileage by asking the
* user to input the number of gallons of gas the car can hold
* and the number of miles it can travel on a full tank.
* The program then calculates and displays the number of miles
* the car can drive per gallon of gas.
* ________________________________________________________
* INPUT
* The program will prompt the user for:
* - The number of gallons of gas the car can hold.
* - The number of miles the car can travel on a full tank.
*
* OUTPUT
* The program will display the number of miles the car can
* drive per gallon of gas.
*
**************************************************************/
#include <iostream> // file for cout and cin
using namespace std;
int main() {
// Declare variables
double gallons, miles, milesPerGallon;
// Ask the user for the number of gallons the car can hold
cout << "Enter the number of gallons the car can hold: ";
cin >> gallons;
// Ask the user for the number of miles the car can drive on a full tank
cout << "Enter the number of miles the car can drive on a full tank: ";
cin >> miles;
// Calculate miles per gallon
if (gallons != 0) {
milesPerGallon = miles / gallons;
// Display the result
cout << "The car can drive " << milesPerGallon << " miles per gallon of gas." << endl;
} else {
cout << "Gallons cannot be zero." << endl;
}
return 0;
}