Question: Write an algorithm and a Java program that reads in a speed in kilometers per hour ( km / h ) and a distance in
Write an algorithm and a Java program that reads in a speed in kilometers per hour kmh and a distance in kilometers, then calculates the equivalent speed in miles per hour mph and the time it takes to travel the given distance at the entered speed.
Use the following formulas:
Speed in miles per hour Speed in kilometers per hour times
Time distance Speed in kilometers per hour
Hint:
Improve the format of the output by showing only two digits after the decimal point for the speed in mph This practice is known as setting the precision to two decimal places. You can use the printf method for formatted output instead of println or print which will be covered in later lectures. For Example: System.out.printfSpeed in miles per hour is f SpeedMilesPerHour;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
