Write a Java program to convert kilometers to miles.

Write a Java program to convert kilometers to miles.

Write a Java program to convert kilometers to miles.

Program
import java.util.Scanner;
public class Main 
{
	public static void main(String[] args) 
	{
		Double kilometers,miles,conversion_factor;
		//Conversion factor: 1 kilometer = 0.621371 miles
		conversion_factor=0.621371;
		
		Scanner s=new Scanner(System.in);
		System.out.println("Enter distance in kilometers: ");
		kilometers=s.nextDouble();
		miles=kilometers * conversion_factor;
		System.out.println(kilometers+" kilometers is equal to "+miles+" miles " );
	}

}


Output:

Enter distance in kilometers: 100
100.0 kilometers is equal to 62.137100000000004 miles



More Questions


26 . Write a Java program to find the area of a triangle.
27 . Write a Java program to convert kilometers to miles.
28 . Write a Java program to convert Celsius to Fahrenheit.
29 . Write a Java Program to Check if a Number is Positive, Negative or Zero.
30 . Write a Java Program to Find the sum of the digits of a number
31 . Write a Java Program to Calculate electricity bill
32 . Write a Java Program to find Armstrong number
33 . Write a java Program to print Armstrong number between 1 to 1000
34 . Write a java Program to Print given number in words
35 . Write a java Program to check the given number is Palindrome or not
36 . Write a java Program to print palindrome number upto N numbers



For latest job updates join Telegram Channel: https://t.me/sateeshm

Apply For The Job

Apply For Job

Java Material

Python Material

PLSQL Material

.Net Material

Java Practice Programs

400 Java Programs