// Arup Guha, editing Bryan Pittard's C++ file from the 2002 BHCSI program.
// 7/14/03
// 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.

import java.io.*;

public class Racecar {

  public static void main(String[] args) throws IOException {

    BufferedReader stdin = new BufferedReader
				(new InputStreamReader(System.in));

    int num_laps;
    double miles_per_lap, avg_speed, gas_tank_size;
    double miles_per_gallon, refuel_time;
	
    // Read in all the necessary information from the user.
    System.out.println("Welcome to the UCF 500!");
    System.out.println("How many laps are in your race?");
    num_laps = Integer.parseInt(stdin.readLine());
    System.out.println("How many miles are in a lap?");
    miles_per_lap = Double.valueOf(stdin.readLine()).doubleValue();

    System.out.println("What is the average speed of the car in miles per hour, when running?");
    avg_speed = Double.valueOf(stdin.readLine()).doubleValue();
    System.out.println("What is the size of the gas tank, in gallons?");
    gas_tank_size = Double.valueOf(stdin.readLine()).doubleValue();

    System.out.println("How miles per gallon does your car get?");
    miles_per_gallon = Double.valueOf(stdin.readLine()).doubleValue();
    System.out.println("How many minutes does it take to refuel your car?");
    refuel_time = Double.valueOf(stdin.readLine()).doubleValue();

    // 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 = Math.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;
    System.out.print("You will average "+overall_avg_speed);
    System.out.println(" miles an hour for the race!");

  }
}




