Question

In: Computer Science

Using Java, Ask for the runner’s name Ask the runner to enter a floating point number...

Using Java,

  1. Ask for the runner’s name

  2. Ask the runner to enter a floating point number for the number of miles ran, like 3.6 or 9.5

  3. 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”)

Solutions

Expert Solution

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!");

    }
}


Related Solutions

Using Java, Ask for the runner’s name Ask the runner to enter a floating point number...
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 Format the numbers with leading 0's if the pace is 8 minutes and 3 second, it should be 8:03 and for marathon time, if its 1 hour and 15 minutes and 9 seconds, it should be 1:15:09 Please read through...
Convert the following floating-point number (stored using IEEE floating-point standard 754) to a binary number in...
Convert the following floating-point number (stored using IEEE floating-point standard 754) to a binary number in non-standard form. 0100_0001_1110_0010_1000_0000_0000_0000
Write the following program in Java. Ask the user to enter the number of rows and...
Write the following program in Java. Ask the user to enter the number of rows and columns for a 2-D array. Create the array and fill it with random integers using (int)(Math.random() * 20) (or whatever number you choose). Then, provide the user with several menu choices. 1. See the entire array. 2. See a specific row. 3. See a specific column. 4. See a specific value. 5. Calculate the average of each row. 6. Calculate the total of each...
Using the simple model for representing binary floating point numbers A floating-point number is 14 bits...
Using the simple model for representing binary floating point numbers A floating-point number is 14 bits in length. The exponent field is 5 bits. The significand field is 8 bits. The bias is 15 Represent -32.5010 in the simple model.
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Using Java! Write a program that ask prompt the user to enter a dollar amount as...
Using Java! Write a program that ask prompt the user to enter a dollar amount as double. Then, calculate how many quarters, dimes, nickels and pennies are in the dollar amount. For example: $2.56 = 10 quarters, 1 dime, 1 nickel and 1 cent. Print all of the values. Hint: Use Modulus operator and integer division when necessary.
in Java Write a method called randomNumber that returns a random floating-point number in the range...
in Java Write a method called randomNumber that returns a random floating-point number in the range of [-20.0, 50.0). (hints: use Random class in the method)
In Java Write a method called findMax that accepts three floating-point number as parameters and returns...
In Java Write a method called findMax that accepts three floating-point number as parameters and returns the largest one.(hints: use conditional statement in the method)
JAVA Write a program that translates a user-input floating-point number between 0 and 4 into the...
JAVA Write a program that translates a user-input floating-point number between 0 and 4 into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B–. Break ties in favor of the better grade; for example 2.85 should be a B. NOTE: Your implementation must include the definition/implementation and use/calling of the method numberGradeToLetterGrade that is passed a double numeric grade to its parameter variable, and returns the...
11) Enter the following using Java. Use for loop to enter student id, student name, major...
11) Enter the following using Java. Use for loop to enter student id, student name, major and grades. Also grades should display their letter grades based on their conditions. After that display the name of students and their info, and also their letter grade After that display the sum of all grades and the average Output Example: Student ID: 0957644 Student Name: Pedro Hernandez Student Major: Business Information Systems Grades for Fall 2020: Introduction to Computer Science using Java: 85,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT