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

Program Specifications Your program will prompt the user for an floating point v

ID: 3542143 • Letter: P

Question

Program Specifications

Your program will prompt the user for an floating point value representing miles/hour. You will reprint that value along with the value converted to the following values:

You can find these measures on the web (try wikipedia), but just in case:

SAMPLE INTERACTION



Please enter a speed in mi1es/hour:1 Original speed in mph is: 1.0 Converted to barleycorn/day is: 4547009.496 Converted to furlongs/fornight is: 2688.0 Converted to Mach number is: 0.00129789357065 Converted to the percentage of the speed of light is: 1.49116539251e-09 Thanks for playing Please enter a speed in mi1es/hour:800 Original speed in mph is: 800.0 Converted to barleycorn/day is: 3637607596.8 Converted to furlongs/fornight is: 2150400.0 Converted to Mach number is: 1.03831485652 Converted to the percentage of the speed of light is: 1.19293231401e-06 Thanks for playing

Explanation / Answer

import java.util.*;
public class miles
{
public static void main(String[] args)
{
double speed;
Scanner in = new Scanner(System.in);
System.out.println("Please enter a speed in miles/hour :");
speed = in.nextDouble();
System.out.println("Original speed in mph is :" + speed);
System.out.printf("Converted to barleycorn/day is :%.1f ",speed*4547009.496);
System.out.println("Converted to furlongs/fortnight is :" + speed*2688.0);
System.out.println("Converted to Mach number is :" + speed*0.00129789357065);
System.out.println("Converted to percentage of speed of light is :" + speed*0.44704/299792458);

System.out.println("Thanks for playing");
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote