How to convert kilometers to miles using Java program?

Distance Units

In school days, we might used ruler to measure the distance between two points. The ruler has the units such as millimeter and centimeter through which we measured the distance. Similarly we have other units such as kilometers and miles to measure the distance between two places.

Example : Distance from New York to California in USA

Convert Kilometers to Miles

Most of the countries including Japan, China, India, Australia and UAE are using kilometers to measure the distance. On the other hand, countries like USA and UK are using miles to measure the distance. Lets understand how to convert kilometers to miles using standard values.

1 mile is equals to 1.609344 kilometers => 1 mile ~ 1.6 kilometers (approximately)

If we want to convert from kilometers to miles, we need to divide the kilometers by 1.609344.

1 kilometer is equals to 1/1.609344 => 0. 621371 miles

Java program to convert kilometers to miles

In this example, we will show you how to write a java program to convert kilometers to miles. The program gets the kilometer value from the user and store it in the variable. Then it is dividing the kilometer value by 1.609344 which will give the values in terms of miles.

Output

Recommended Articles