In: Computer Science
Using Java,
Ask for the runner’s name
Ask the runner to enter a floating point number for the number of miles ran, like 3.6 or 9.5
Then ask for the number of hours, minutes, and seconds it took to run
A marathon is 26.219 miles
Pace is how long it takes in minutes and seconds to run
1 mile.
Example Input:
What is your first name? // user enters Pheidippides
How far did you run today? 10.6 // user enters 10.6
miles
How long did it take? Hours: 1 // user enters 1 hours
Minutes: 34 // user enters 34 minutes
Seconds: 17 // user enters 17 seconds
Example Output:
Hi Pheidippides
Your pace is 8:53 (minutes: seconds)
At this rate your marathon time would be 3:53:12
Good luck with your training!
After your program tells the user what their pace is,
your program will build a table showing the following columns. The
pace table should start with the fastest man time which is Eliud
Kipchoge.
Example:
Pace Table
Pace Marathon
4:37 2:01:04 ←- Eliud Kipchoge
5:17 2:18:41
5:57 2:36:18
6:37 2:53:55
7:18 3:11:32
7:58 3:29:09
8:38 3:46:46
8:53 3:53:12 ← Pheidippides
The table should start with the World Record pace and time which is 4:37, 2:01:04.
Then continues in 17 minute and 37 second intervals until you reach the marathon time of the user.
Use a static function to print the pace table, introduce a while loop.
For the first person it should call a printTable function
Example : printTable (pace, “<--- Eliud Kipchoge”) something like that
The pace table continues until it reaches the user
printTable (myPace, name) something like that
For the marathon and pace time, make sure the format has 0’s if the time is 9 seconds, it should be 09.
Use the printf statement for formatting output (“02d %f%s”)
Thanks for the question. Below is the code you will be needing Let me know if you have any doubts or if you need anything to change. // Please post the Additional Requirements as a separate question, I could have done it but at least you should have shared the details World Record Pace Times from the internet. Please share the Pace Table along with the question. Thank You !! =========================================================================== import java.util.Scanner; public class Marathon { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("What if your first name? "); String name = scanner.nextLine(); System.out.print("How far did you run today? "); double distance = scanner.nextDouble(); System.out.print("How long it take? hours: "); int hours = scanner.nextInt(); System.out.print(" ? minutes: "); int mins = scanner.nextInt(); System.out.print(" ? seconds: "); int seconds = scanner.nextInt(); int totalSeconds = hours * 60 * 60 + mins * 60 + seconds; int pace = (int) (totalSeconds / distance); System.out.printf("Hi %s\n", name); System.out.printf("Your pace is %d:%d (minutes : seconds)\n", (pace / 60), (pace % 60)); // 1 Marathon = 26.25 miles int marathonTime = (int) (26.25 * pace); int marathonHours = marathonTime / 3600; marathonTime = marathonTime % 3600; int marathonMins = marathonTime / 60; int marathonSeconds = marathonTime % 60; System.out.printf("At this rate your marathon time would be %d:%d:%d\n", marathonHours , marathonMins, marathonSeconds); System.out.printf("\nGood luck with your training!"); } }