FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 10   



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

import java.util.Scanner;

public class MathUnitConversions7 {

    public static void main(String[] args) {

        double miles;

        Scanner in = new Scanner(System.in);

        System.out.println("Please enter miles:");
        miles = in.nextDouble();

        double kilometers = miles * 1.6;

        System.out.println(kilometers + " Kilometers");

    }
}

Output:

Please enter miles:
25
40.0 Kilometers



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News