Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have been assigned as the l ead programmer for the World Track and Field Cha

ID: 3705468 • Letter: Y

Question

You have been assigned as the l

ead

programmer for the World Track and

Field Championships! The 100 meter

dash is one of the highlights of this

competition and is considered by many

to demonstra

te the world’s fastest

human. Your job is to take the top

finish time (given in seconds with two

digits of precision to the right of the

decimal point) for the 100 meter dash

and do so

me conversions to find out

how fast the person was traveling in:

?

meters per second

?

feet per second

?

kilometers per hour

?

miles per hour

In addition, you must also determine how long it would take the person to run one mile. And

finally, you must determine how long it would take the person to run 100 yards.

Your pr

ogram design should ma

ke

use of java methods to

properly

encapsulate

variables and

processing.

The result of

each conversion you perform should be displayed and clearly labeled, as

demonstrated in the sample “run” below (NOTE: the actual numeric results are not displayed

that is for you to figure out):

Example run:

Please enter the winning time of the race:

15.00

The person was traveling at a rate of:

x.xx meters per second,

y.yy feet per second,

z.zz kilometers per hour,

y.yy miles per hour,

It would take m minutes and n.nn seconds for the person to run

one mile.

It would take t.tt seconds for the per

son to run 100 yards.

THIS IS MY CODE:

import java.lang.Math;
import java.util.*;

public class Track
{
   public static void main(String[] args)
   {
   double time_to_win,in_mt_sec,in_ft_sec,in_km_hr,in_mile_hr,feet,time_in_1mile,time_in_1mile_min,time_in_1mile_sec,time_in_100yards; // Used "_" so its easier for me to read
  
   System.out.println("Please enter the winning time of the race:"); // This will prompt the user
  
   Scanner s = new Scanner(System.in);
   time_to_win=s.nextDouble();
   in_mt_sec=100/time_to_win;
   feet=100/3.28;
   in_ft_sec=feet/time_to_win;
   in_km_hr=in_mt_sec/3.6;
   in_mile_hr=in_km_hr/0.62;
   time_in_1mile=time_to_win*1609.34/100; // 1 mile = 1609.34 meters
   time_in_1mile_min=time_in_1mile/60;
   time_in_1mile_sec=time_in_1mile%60;
   time_in_100yards=time_to_win*91.44/100; // 100 yards = 91.44 meters
  
   System.out.println("The Person was travelling at the rate of:"); //This will show the answers for the user
   System.out.println(in_mt_sec+" meters per second,");
   System.out.println(in_ft_sec+" feet per second,");
   System.out.println(in_km_hr+" kilometers per hour,");
   System.out.println(in_mile_hr+" miles per hour,");
   System.out.println("It would take "+time_in_1mile_min+" minutes and "+time_in_1mile_sec+" seconds for the person to run one mile.");
   System.out.println("It would take "+time_in_100yards+" seconds for the person to run 100 yards.");

   }
}

HOWEVER MY ANSWER HAS TOO MANY DECIMALS

Explanation / Answer

Program



import java.lang.Math;
import java.util.*;

import java.text.DecimalFormat;


public class Track {


    public static void main(String[] args) {
      double time_to_win,in_mt_sec,in_ft_sec,in_km_hr,in_mile_hr,feet,time_in_1mile,time_in_1mile_min,time_in_1mile_sec,time_in_100yards; // Used "_" so its easier for me to read
   DecimalFormat df = new DecimalFormat("##.##"); // to print a decimal number with 2 digits after decimal point
    System.out.println("Please enter the winning time of the race:"); // This will prompt the user
  
    Scanner s = new Scanner(System.in);
    time_to_win=s.nextDouble();
    in_mt_sec=100/time_to_win;
    feet=100/3.28;
    in_ft_sec=feet/time_to_win;
    in_km_hr=in_mt_sec/3.6;
    in_mile_hr=in_km_hr/0.62;
    time_in_1mile=time_to_win*1609.34/100; // 1 mile = 1609.34 meters
    time_in_1mile_min=time_in_1mile/60;
    time_in_1mile_sec=time_in_1mile%60;
    time_in_100yards=time_to_win*91.44/100; // 100 yards = 91.44 meters
  
    System.out.println("The Person was travelling at the rate of:"); //This will show the answers for the user
    System.out.println(df.format(in_mt_sec)+" meters per second,");
    System.out.println(df.format(in_ft_sec)+" feet per second,");
    System.out.println(df.format(in_km_hr)+" kilometers per hour,");
    System.out.println(df.format(in_mile_hr)+" miles per hour,");
    System.out.println("It would take "+df.format(time_in_1mile_min)+" minutes and "+df.format(time_in_1mile_sec)+" seconds for the person to run one mile.");
    System.out.println("It would take "+df.format(time_in_100yards)+" seconds for the person to run 100 yards.");
    }
   
}

Output

Please enter the winning time of the race:
15
The Person was travelling at the rate of:
6.67 meters per second,
2.03 feet per second,
1.85 kilometers per hour,
2.99 miles per hour,
It would take 4.02 minutes and 1.4 seconds for the person to run one mile.
It would take 13.72 seconds for the person to run 100 yards.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote