X1530: Average Speed

Write a function in Java that calculates the average speed of a trip. Given four ints: distance (miles), days, hours, and minutes;
calculate and return the average speed in miles per hour as a double.

Be careful with integer division! Make sure you get a decimal result, not just the whole number part.

Example: A trip covers 370 miles over 2 days, 6 hours, and 12 minutes Convert the total time into hours: 54.2 hours Average speed during the trip: about 6.826568265 miles per hour

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.