Computer Science, asked by vidhikadlag, 10 months ago

write a java program to input length in kilometers from the user. convert and display it in the following units - miles,meter,feet and inches

input : enter the length in kilometer :50
output : miles : 31.069409999999998
meter: 50000.0
feet: 164041.995
inches: 1968503.9400000002

Answers

Answered by ridhimakh1219
2

write a java program to input length in kilometers from the user. convert and display it in the following units - miles,meter,feet and inches

Explanation:

Java program to input length in kilometers from the user and convert it into and display it in miles,meter,feet and inches

import java.util.Scanner;

public class Main {

   public static void main(String[] Strings) {

       Scanner input = new Scanner(System.in);

       System.out.print("enter the length in kilometer: ");

       double km = input.nextDouble();

       double meter = km * 1000.0; // 1km=1000m

       double feet = km * 3280.84; //since 1km=3280.84 feet

       double inch = km * 39370.1; //since 1 km=39370.1 inches

       double miles = km * 0.621371192; //since 1 km=0.0.621371192 miles

       System.out.println(km+ " kilometers is " + miles + " in miles");

       System.out.println( km+ " kilometers is " + meter + " in meters");

       System.out.println(km+ " kilometers is " + feet + " in feets");

       System.out.println(km+ " kilometers is " + inch + " in inches");

   }

}

Output

enter the length in kilometer: 50                                                          

50.0 kilometers is 31.0685596 in miles                                                  

50.0 kilometers is 50000.0 in meters                                            

50.0 kilometers is 164042.0 in feets                                                          

50.0 kilometers is 1968505.0 in inches

Similar questions