Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa Java-Beginners Distance in meters

View Questions and Answers by Category


Have Programming Question? Ask it here!

Distance in meters
1 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners

View Answers

October 9, 2009 at 2:09 PM

Hi Friend,

Try the following code:

import java.util.*;
public class ConvertMeter{
public void showKilometers(double meters){
double kilometers = meters * 0.001;
System.out.println(meters+" meters is "+kilometers+" kms");
public void showInches(double meters){
double inches = meters * 39.37;
System.out.println(meters+" meters is "+inches+" inches");
public void showFeet(double meters){
double feet = meters * 3.281;
System.out.println(meters+" meters is "+feet+" feet");
public void menu(){
System.out.print("Enter a distance in meters: ");
Scanner scan=new Scanner(;
double m=scan.nextDouble();
boolean quit = false;

System.out.println("1. Convert to kilometers");
System.out.println("2. Convert to inches");
System.out.println("3. Convert to feet");
System.out.println("4. Quit the program");
System.out.print("Enter your choice: ");
int menu = scan.nextInt();
switch(menu) {
case 1:
case 2:
case 3:
case 4:
quit = true;
System.out.println("Invalid Entry!");

while (!quit);

public static void main(String[]args){
ConvertMeter convert=new ConvertMeter();;


Related Tutorials/Questions & Answers:
Distance in meters - Java Beginners
a distance in meters. The program will then present the following menu of selections... should not accept negative numbers for the distance in meters. ? If the user...?s input is shown in bold. Enter a distance in meters: 500 1. Convert
Distance conversion - Java Beginners
(){ System.out.print("Enter a distance in meters: "); Scanner scan=new Scanner( conversion  Write an application that reads a distance... the distance to kilometres, feet and inches, according to the user?s selection
class distance
class distance  class distance-integer data member km1,km2,km3,m1,m2,m3. run()-to input the two distance and add them in the third. display()-to display the total distance. display the constructor if required
Edit Distance
Edit Distance  I want java programming ask from user input two string and the program find the edit distance between two strings and find table and optimal solution using GUI
Another distance conversion - Java Beginners
[]){ System.out.print("Enter distance in meters : "); BufferedReader br = new BufferedReader(new...); } double value=Double.parseDouble(distance); System.out.println(distance+" meters...Another distance conversion  Write an application that reads
Convert Feet To Meters
Convert Feet To Meters       In this section, you will learn to convert Feet to Meters. The following program helps you in converting Feet to Meters.  Code
Convert Inches To Meters
Convert Inches To Meters       In this section, you will learn to Inches To Meters. The following program helps you in converting Inches To Meters.  Code Description
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
Delhi to Udaipur by road distance
Delhi to Udaipur by road distance  delhi to udaipur by road distance
Road distance using Java - Java Beginners
Road distance using Java  Dear All i am calculating the straight line distance between two latlong points using the simple mathematical formula but i need the Real Road Driving Distance // protected double distance(double pX
Hill stations near Delhi distance
Hill stations near Delhi distance   Hi, Can any one tell the distances of the Hill stations near Delhi? Thanks
Distance learning business management
Distance learning business management courses are on high demand today.... But those students should not worry as many institutions have started distance... for the future and skilled workforce. Distance learning business management courses
Hill Stations near Delhi distance
Distance of Major Hill Stations From Delhi  In this page we have listed all the Hill Stations near Delhi with their distance from central Delhi... and northeastern India. List of Hill Stations near Delhi with distance Sr
VoIP Long Distance
VoIP Long Distance          VoIP Designing a Long-Distance Network The long-distance Voice over IP (VoIP) network solution is a set of network design
GUI and how to convert a distance - Java Beginners
application that can be is used to convert a distance unit in miles into its...=new JTextField(20); t5=new JTextField(20); l1=new JLabel("Enter distance...){ String value=t1.getText(); double distance=Double.parseDouble(value
How can i display the distance of a line drawing randomly?
How can i display the distance of a line drawing randomly?  How can i display the distance of a line drawing randomly
loop to input multiple points to calculate final distance and speed
loop to input multiple points to calculate final distance and speed  ...; private double distance; public Travel() { time=0; distance=0... getDistance() { return distance; } public static void main (String[] args
What is Differential GPS?
the accuracy to within two meters of the actual position for moving objects... two receivers within a distance of a few hundred kilometers receive have the same amount of errors, as they have traveled the same amount of distance
Techniques to Improve GPS Accuracy
technology developed so far, with accuracy levels of within 4-20 meters or so... of readings to within 1-3 meters of the object, as compared to the 4-20 meters
How GPS Measures Distances
of an object using distance measurements from at least three satellites. Let us now examine how distance from the satellites is calculated. The Principle... obtain the distance from city A to city B as 240 miles by multiplying the speed of 80
Golden Triangle Tour - Enchanting Golden Triangle Tour
The best part of Golden Triangle Tour is that all these three cities are just four to five hours driving distance from each other
Kilometers per Liter to Miles per Gallon
: The distance traveled by a vehicle which is running on gasoline or diesel fuel in a kilometer.  Miles per Gallon: The distance traveled by a vehicle
What is UWB?
What is UWB?       UWB (Ultra Wideband) is a radio frequency platform that is used in the wireless device for communicating  within a short distance with  high accuracy
A Brief Introduction to Travel
A Brief Introduction to Travel In simple words, Travel is the moving of objects or people between two geographical locations of relative distance. At times Introduction to Travel can also include movements between different
VoIP Termination
Protocol (VoIP) Termination provides reliable long distance connectivity for carriers... distance VoIP access to residential and commercial customers. There are few... network to the PSTN for terminating domestic long distance calls * Nationwide
VoIP Companies
VoIP Companies          VoIP Services providers and Enterprise VoIP first revolutionized long distance exchange services. Almost overnight, consumers could
Android GPS tracking
tracks and view live statistics of time, speed, distance, and elevation Once
java beginners
: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds... return the distance, in meters, that the object has fallen during that time..., the following formula can be used to determine the distance of the object falls
c programme
=0.9 is dropped initially from a√?¬†√?¬†height of 10 meters, after 1 bounce the height will be 9 meters, after 2 bounces it will be 8.1 meters and so on.√?¬†√?¬†The total distance the ball has traveled after one bounce is 10 + 9 = 19 meters
Visit to Fatehpur Sikri
Sikri: The historical township of Fatehpur Sikri is at a distance of about 30