Home Java Java-conversion Convert Meters To Miles



Convert Meters To Miles
Posted on: February 27, 2008 at 12:00 AM
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.

Related Tags for Convert Meters To Miles:
cconvertiohelpthisprogramtolearnrameareilsectioninconvertingmpsesmeprosisllmeterfolloweaarrtwingssthprmionogrolo


More Tutorials from this section

Ask Questions?    Discuss: Convert Meters To Miles  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.