// Renee V. Lopez CS1A Chapter 3, P. 143, #1
/**************************************************************************
* CALCULATE MILES PER GALLON
* _____________________________________________________________________________
* This program computes the distance a car can travel on one
* gallon of gas based on gas tank capacity and average
* miles-per-gallon (MPG) rating for city and highway driving.
*
* Computation is based on the formula:
* Distance = Total Miles / Number of Gallons
* _____________________________________________________________________________
* INPUT
* numOfGallons : Gas tank capacity
* totalMiles : Total miles driven
* milesPerGallon : Miles per gallon
*
* OUTPUT
* distance : Distance car can travel
*
******************************************************************************/
#include <iostream>
using namespace std;
int main() {
int numOfGallons; // Gas tank capacity in gallons
int totalMiles; // Total miles driven on a full tank
float milesPerGallon; // Miles per gallon the car can achieve
// Request user input for tank capacity and total miles driven
cout << "Enter the number of gallons of gas the car can hold: ";
cin >> numOfGallons;
cout << "Enter the number of miles it can be driven on a full tank: ";
cin >> totalMiles;
// Calculate miles per gallon
milesPerGallon = float(totalMiles) / numOfGallons;
// Display the result
cout << "Miles per gallon is: " << milesPerGallon << endl;
return 0;
}