(Average speed in kilometers) Assume a runner runs 24 miles in 1 hour, 40 minutes, and 35 seconds. Write a program that displays the average speed in kilometers per hour. (Note that 1 mile is 1.6 kilometers.)
Solution
//Program - 12
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Miles / (hour + (minutes / 60) + (seconds / 3600)) * 1.6");
System.out.println("24 / (1 + (40 / 60) + (35 / 3600)) * 1.6");
System.out.println((24 / (1 + (40 / 60.0) + (35 / 3600.0))) * 1.6);
}
}
OUTPUT
Miles / (hour + (minutes / 60) + (seconds / 3600)) * 1.6
24 / (1 + (40 / 60) + (35 / 3600)) * 1.6
22.90637945318973
If you have any doubts or questions, please let me know.