In this section, you will learn to convert Miles to
Kilometers. The following program helps you in converting Miles to
To convert Miles to Kilometers we have used a formula "km = miles * 1.609344;". The compiler will ask to enter the number of Miles from the keyboard due to the method "BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));". Here we have taken miles to be of type float. To avoid loss of precession we have cast the output to be in float.
Here is the code of the program:
Output of the program:
Enter a number of miles: 1
1.0 miles is 1.609344 kilometers.
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Convert Miles To Kilometers
Post your Comment