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
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");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.