Converts the length value from miles to kilometers. - Java java.lang

Java examples for java.lang:Math Convert

Description

Converts the length value from miles to kilometers.

Demo Code


//package com.java2s;

public class Main {
    /**//from   ww w  . j  av  a  2s .c om
     * Converts the length value from miles to kilometers.
     *
     * @param miles value in miles
     * @return value in kilometers
     */
    public static double convertMiles2Kilometer(double miles) {
        return miles * 1.609344d;
    }

    /**
     * Converts the length value from miles to kilometers.
     *
     * @param miles value in miles
     * @return value in kilometers
     */
    public static int convertMiles2Kilometer(int miles) {
        return (int) Math.round(convertMiles2Kilometer((double) miles));
    }
}

Related Tutorials