Convert Meters To Miles

In this section, you will learn to convert Meters To Miles. The following program helps you in converting Meters To Miles.

Convert Meters To Miles

In this section, you will learn to convert Meters To Miles. The following program helps you in converting Meters To Miles.

Convert Meters To Miles

Convert Meters To Miles

     

In this section, you will learn to convert Meters To Miles. The following program helps you in converting Meters To Miles. 

Code Description:

To convert Meters To Miles we have used a formula "meter = * 0.00062137119;". The compiler will ask to enter the number of Meters from the keyboard due to the method  "
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));". Here we have taken meter to be of type Int. To avoid loss of precession we have cast the output to be in double.

Here is the code of the program:

import java.io.*;
import java.util.*;

class MetersToMiles{
  public static void main (String[] args)throws
  
Exception{
  // 1 meters = 0.00062137119 miles;
  BufferedReader bf = new BufferedReader
  (
new InputStreamReader(System.in));
  System.out.print("Enter the Meters:");
  int meter = Integer.parseInt(bf.readLine());
  double miles = meter * 0.00062137119;
  System.out.println("Miles: " + miles);
  }
}

Output of the program:

C:\unique>javac MetersToMiles.java

C:\unique>java MetersToMiles
Enter the Meters:1
Miles: 6.2137119E-4

C:\unique>java MetersToMiles
Enter the Meters:4
Miles: 0.00248548476

C:\unique>

Download this example.