/////////////////////////////////////////////////////////////////////
// Student name: Johnny B. Goode
// Student ID: 123-45-6789
// Course: CS161 Summer 97
// Assignment: #1
// Due date: 7-1-97
//
// Description: mpg.cpp
//
// This program prompts the user for the starting
// mileage, ending mileage, and gallons used. Then
// it calculates the miles per gallon and prints
// the result to the screen.
/////////////////////////////////////////////////////////////////////
#include <iostream.h>
#include <iomanip.h>
void main(void)
{
int start_mileage; // the mileage before the trip
int end_mileage; // the mileage after the trip
float gallons_used; // the number of gallons used
float miles_per_gallon; // the fuel efficiency
//prompt the user for the starting mileage
cout << "Enter the starting mileage: ";
// put the value in start_mileage
cin >> start_mileage;
// prompt the user for the ending mileage
cout << "Enter the ending mileage: ";
// put the value in end_mileage
cin >> end_mileage;
// prompt the user for the gallons used
cout << "How many gallons of gas were used: ";
// put the value in gallons_used
cin >> gallons_used;
// calculate the MPG
miles_per_gallon = (end_mileage - start_mileage) / gallons_used;
// print out the result on the terminal to 2 decimal places
cout << "Your MPG is " << setprecision(2);
cout << miles_per_gallon << endl;
}