// Torrez, Elaine CS1A Chapter 2 P. 81, #1
/******************************************************************************************
*
* CALCULATE MILES PER GALLON
*
* --------------------------------------------------------------------------------
* This program calculates a car’s gas mileage. It uses the number of gallons of
* gas the car can hold and the number of miles it can be driven on a full tank.
* The program then calculates and displays the number of miles per gallon.
* --------------------------------------------------------------------------------
*
* INPUT
* gallons : Number of gallons of gas the car can hold
* miles : Number of miles the car can be driven on a full tank
*
* OUTPUT
* mpg : Miles per gallon of gas
*
*******************************************************************************************/
#include <iostream>
#include <iomanip> // Included for fixed and setprecision
using namespace std;
int main ()
{
double gallons; // INPUT number of gallons the tank holds
double miles; // INPUT number of miles the car can drive on a full tank
double mpg; // OUTPUT miles per gallon
// Hardcoded test values (change if needed)
gallons = 12;
miles = 144;
// Calculate miles per gallon
mpg = miles / gallons;
// Format and display result
cout << fixed << setprecision(1);
cout << miles << " miles / " << gallons << " gallons = "
<< mpg << " miles per gallon." << endl;
return 0;
}