Home Java Java-conversion Convert Meters To Miles
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Convert Meters To Miles

Advertisement
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. 

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.

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 27, 2008

Ask Questions?    Discuss: Convert Meters To Miles  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com