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 (km/h) 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 0.621671
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.printf("Speed in miles per hour is %4.2f", SpeedMilesPerHour);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!