Share on Google+Share on Google+

Distance in meters
1 Answer(s)      7 years 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
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
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
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
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null