I was tasked to create a program that would calculate how fast you must go to reach a certain distance (miles per hour) at a certain time (in hours). You are supposed to consider a 5 minute break for every 100 miles. Also, the program has to be written using 4 methods and a main method. I already did a majority of the program but I don't know how to properly output my results. I am positive that I am doing something wrong with one of the methods but I don't know how to fix it. Heres what I have:
import java.util.Scanner;
public class I95Machine {
public static void userMessage() {
System.out.println("Welcome to I95 Speed Machine");
System.out.println("You will have to supply:\n+ The distance you want to travel, in miles\n+ The time you have available, in hours");
}
public static double computeTravelSpeedOne(double inputDist, double inputTime) {
double stopTime, travelSpeed;
int timeQuotient;
timeQuotient = (int) (inputDist / 100);
stopTime = timeQuotient * 5;
if ((timeQuotient % 100) > 0) {
stopTime += 5;
}
stopTime /= 60;
inputTime = inputTime - stopTime;
travelSpeed = inputDist / inputTime;
if (inputTime > 0) {
return travelSpeed;
} else {
return 0.0;
}
}
public static double inputDistAndTime() {
Scanner keyboard = new Scanner(System.in);
double distNum = 0, timeNum = 0, distance, time;
System.out.print("Enter distance to travel : ");
distNum = keyboard.nextDouble();
distance = distNum;
System.out.print("Enter time available : ");
timeNum = keyboard.nextDouble();
time = timeNum;
return computeTravelSpeedOne(distance, time);
}
public static void displayOutput(double travelSpeed) {
boolean speedLim = computeTravelSpeedOne() > 65;
System.out.print("You will have to travel at ");
System.out.println(computeTravelSpeedOne() + " MPH");
System.out.print("Over the speed limit : ");
System.out.print(speedLim);
}
public static void main(String[] args) {
userMessage();
inputDistAndTime();
displayOutput();
}
}