// Bryan Pittard
// 7/12/02
// This program asks the user several pieces of information concerning a
// car in a race around a track and outputs the average speed of the car
// for the race.
#include <iostream.h>
#include <math.h>

int main()
{
	int num_laps;
	double miles_per_lap, avg_speed, gas_tank_size, miles_per_gallon, refuel_time;
	
        // Read in all the necessary information from the user.
	cout << "Welcome to the UCF 500!" << endl;
	cout << "How many laps in your race?" << endl;
	cin >> num_laps;
	cout << "How many miles are in a lap?" << endl;
	cin >> miles_per_lap;
	cout << "What is the average speed of the car in miles per hour, when running?" << endl;
	cin >> avg_speed;
	cout << "What is the size of the gas tank, in gallons?" << endl;
	cin >> gas_tank_size;
	cout << "How miles per gallon does your car get?" << endl;
	cin >> miles_per_gallon;
	cout << "How many minutes does it take to refuel your car?" << endl;
	cin >> refuel_time;

	// compute total miles per race
	double total_miles = num_laps*miles_per_lap;

	// compute time to complete race without stopping
	double drive_time = total_miles / avg_speed;

	// compute number of refuels per race
	double miles_per_tank = gas_tank_size*miles_per_gallon;
	double num_refuels = ceil(total_miles/miles_per_tank-1);

	// compute total refuel time (in hours)
	double total_refuel_time = num_refuels*refuel_time/60;

	// compute total time for race
	double race_time = total_refuel_time+drive_time;

	// compute avg speed per race
	double overall_avg_speed = total_miles/race_time;
	cout << "You will average " << overall_avg_speed << " miles an hour for the race!" << endl; 
}




