logo image

Java program to convert kilometers to miles

Following program shows you how to convert kilometers to miles. In this program we get kilometers from user, once we get those we need to divide with 1.6 so that we get in miles

import java.util.Scanner;

public class MathUnitConversions6 {

	public static void main(String[] args) {

		double kilometers;

		System.out.println("Please enter kilometers:");

		Scanner in = new Scanner(System.in);
		kilometers = in.nextDouble();

		double miles = kilometers / 1.6;

		System.out.println(miles + " Miles");



Please enter kilometers:
6.25 Miles