Using java Please dont include methods in program I am a beg

Using java: Please don\'t include methods in program. I am a beginner - thank you.     NOTE: please make sure the program is properly working because I already asked this question and he/she made a mistake on their calculation which made the program give out incorrect output.                 

Write a program that prompts the user to ask for the runner name, how far they ran, and how long it took. Please then calculate how fast the runner actually ran. Then you will calculate how long it takes to run a 10K, and how long it would take to run a marathon if the runner were able to maintain this pace. You will also show the runner what his/her training pace is. 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.

Example user enters Pheidippides What is your first name? How far did you run today? 1.5 user enters 1.5 miles How long did it take? hours: 0 user enters 0 hours minutes: 12 user enters 12 minutes seconds: 0 user enters 0 seconds Hi Pheidippides, Your pace is 8:0 (minutes seconds) At this rate your marathon time would be 3:29:36 and your 10K time would be 0:49:41 Good luck with your training! Definitions: 10K a 10 kilometer race. marathon a 26.2 mile long race. 1 mile 1.61 kilometers pace how long it takes (in minutes and seconds to run 1 mile. Example: if I can run 1 mile in 5 minutes and 23 seconds, then my pace is 5:23.

Solution


import java.util.Scanner;

    public static void main(String[] args) {
        // TODO code application logic here
         Scanner scanner = new Scanner(System.in);
         float mile,pace;
         float hr,min,sec; float tim;//time in minutes
    System.out.print(\"What is your name? \");
    String name = scanner.next();
  
    System.out.println(\"Hoe far did you run today?\");
    mile = scanner.nextFloat();
    System.out.println(\"How long did it take?\ hour:\");
    hr= scanner.nextFloat();
    System.out.println(\"minutes:\");
    min= scanner.nextFloat();
    System.out.println(\"seconds:\");
    sec = scanner.nextFloat();
    System.out.println(\"Hi \"+ name);
    tim = min + (hr*60)+(sec/60);
    float whole = (tim/mile);
        int minpart=(int)(Math.floor(whole));
        int secpart = (int)(Math.ceil((whole - minpart)*60));
      
      System.out.println(\"your pace is\" +minpart+\":\" +secpart+\"(minutes:seconds)\");
     float martime=whole*26.2f;
     int hrprt=(int)(martime/60);
     int x=(int)(martime%60);
     int martime1=(int)(Math.floor(x));
     int sectime1=(int)(Math.ceil((x-martime1)*60));
     System.out.println(\"At this rate your marathon time would be\"+hrprt+\":\"+martime1+\":\"+sectime1);
    float tenktim = (whole*10)/1.61f;
    int hrprt2=(int)(tenktim/60);
     int y=(int)(tenktim%60);
     int martime2=(int)(Math.floor(y));
     int sectime2=(int)(Math.ceil((y-martime2)*60));
          System.out.println(\"and your 10K time would be\"+hrprt2+\":\"+martime2+\":\"+sectime2);

    }
  

Using java: Please don\'t include methods in program. I am a beginner - thank you. NOTE: please make sure the program is properly working because I already aske

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site