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 " ); } }
Enter distance in kilometers: 100
100.0 kilometers is equal to 62.137100000000004 miles