Distance in meters

Distance in meters

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(System.in);
double m=scan.nextDouble();
boolean quit = false;

do{
System.out.println();
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.println();
System.out.print("Enter your choice: ");
int menu = scan.nextInt();
switch(menu) {
case 1:
showKilometers(m);
break;
case 2:
showInches(m);
break;
case 3:
showFeet(m);
break;
case 4:
quit = true;
System.out.println("Bye!");
break;
default:
System.out.println("Invalid Entry!");
}
}

while (!quit);

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

Thanks









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(System.in...Distance conversion  Write an application that reads a distance... the distance to kilometres, feet and inches, according to the user?s selection
Advertisements
Version of com.quigley>meters dependency
List of Version of com.quigley>meters dependency
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
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
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
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
Maven Dependency meters >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of com.quigley >> meters version0.0.1 in your project
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 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
Maven Repository/Dependency: com.quigley | meters
Maven Repository/Dependency of Group ID com.quigley and Artifact ID meters. Latest version of com.quigley:meters dependencies. # Version Release Date You can read more at: Maven
ModuleNotFoundError: No module named 'Distance'
ModuleNotFoundError: No module named 'Distance'  Hi, My Python... 'Distance' How to remove the ModuleNotFoundError: No module named 'Distance... to install padas library. You can install Distance python with following
Delhi to Udaipur by road distance
Delhi to Udaipur by road distance  delhi to udaipur by road distance
data science distance learning
data science distance learning  Hi, I am beginner in Data Science... science distance learning Try to provide me good examples or tutorials links so that I can learn the topic "data science distance learning". Also tell
data analytics distance learning
data analytics distance learning  Hi, I am beginner in Data Science... analytics distance learning Try to provide me good examples or tutorials links so that I can learn the topic "data analytics distance learning"
artificial intelligence distance learning
artificial intelligence distance learning  Hi, I am beginner in Data...: artificial intelligence distance learning Try to provide me good examples... distance learning". Also tell me which is the good training courses
ai distance learning
ai distance learning  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: ai distance... the topic "ai distance learning". Also tell me which is the good training
distance data science masters
distance data science masters  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: distance... that I can learn the topic "distance data science masters". Also tell me
machine learning distance learning
machine learning distance learning  Hi, I am beginner in Data...: machine learning distance learning Try to provide me good examples or tutorials links so that I can learn the topic "machine learning distance learning"
ModuleNotFoundError: No module named 'distance-locker'
ModuleNotFoundError: No module named 'distance-locker'  Hi, My... named 'distance-locker' How to remove the ModuleNotFoundError: No module named 'distance-locker' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'distance-metrics'
ModuleNotFoundError: No module named 'distance-metrics'  Hi, My... named 'distance-metrics' How to remove the ModuleNotFoundError: No module named 'distance-metrics' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'edit-distance'
ModuleNotFoundError: No module named 'edit-distance'  Hi, My... 'edit-distance' How to remove the ModuleNotFoundError: No module named 'edit-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'faces-distance'
ModuleNotFoundError: No module named 'faces-distance'  Hi, My... named 'faces-distance' How to remove the ModuleNotFoundError: No module named 'faces-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'string-distance'
ModuleNotFoundError: No module named 'string-distance'  Hi, My... named 'string-distance' How to remove the ModuleNotFoundError: No module named 'string-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'trajectory_distance'
ModuleNotFoundError: No module named 'trajectory_distance'  Hi, My... named 'trajectory_distance' How to remove the ModuleNotFoundError: No module named 'trajectory_distance' error? Thanks   Hi
ModuleNotFoundError: No module named 'tree_distance'
ModuleNotFoundError: No module named 'tree_distance'  Hi, My... 'tree_distance' How to remove the ModuleNotFoundError: No module named 'tree_distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Brew-Distance'
ModuleNotFoundError: No module named 'Brew-Distance'  Hi, My... 'Brew-Distance' How to remove the ModuleNotFoundError: No module named 'Brew-Distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'categorical-distance'
ModuleNotFoundError: No module named 'categorical-distance'  Hi...: No module named 'categorical-distance' How to remove the ModuleNotFoundError: No module named 'categorical-distance' error? Thanks   Hi
ModuleNotFoundError: No module named 'dask-distance'
ModuleNotFoundError: No module named 'dask-distance'  Hi, My... 'dask-distance' How to remove the ModuleNotFoundError: No module named 'dask-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'datetime-distance'
ModuleNotFoundError: No module named 'datetime-distance'  Hi, My... named 'datetime-distance' How to remove the ModuleNotFoundError: No module named 'datetime-distance' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'distance-locker'
ModuleNotFoundError: No module named 'distance-locker'  Hi, My... named 'distance-locker' How to remove the ModuleNotFoundError: No module named 'distance-locker' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'distance-metrics'
ModuleNotFoundError: No module named 'distance-metrics'  Hi, My... named 'distance-metrics' How to remove the ModuleNotFoundError: No module named 'distance-metrics' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-distance'
ModuleNotFoundError: No module named 'django-distance'  Hi, My... named 'django-distance' How to remove the ModuleNotFoundError: No module named 'django-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'earth_distance'
ModuleNotFoundError: No module named 'earth_distance'  Hi, My... named 'earth_distance' How to remove the ModuleNotFoundError: No module named 'earth_distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'edit-distance'
ModuleNotFoundError: No module named 'edit-distance'  Hi, My... 'edit-distance' How to remove the ModuleNotFoundError: No module named 'edit-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'effective-distance'
ModuleNotFoundError: No module named 'effective-distance'  Hi, My... named 'effective-distance' How to remove the ModuleNotFoundError: No module named 'effective-distance' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'faces-distance'
ModuleNotFoundError: No module named 'faces-distance'  Hi, My... named 'faces-distance' How to remove the ModuleNotFoundError: No module named 'faces-distance' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'jargon-distance'
ModuleNotFoundError: No module named 'jargon-distance'  Hi, My... named 'jargon-distance' How to remove the ModuleNotFoundError: No module named 'jargon-distance' error? Thanks   Hi, In your python
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
mtech in machine learning distance
mtech in machine learning distance  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: mtech in machine learning distance Try to provide me good examples or tutorials
Hill stations near Delhi distance
Hill stations near Delhi distance   Hi, Can any one tell the distances of the Hill stations near Delhi? Thanks
masters in data science distance learning
masters in data science distance learning  Hi, I am beginner in Data...: masters in data science distance learning Try to provide me good examples... distance learning". Also tell me which is the good training courses
msc artificial intelligence distance learning
msc artificial intelligence distance learning  Hi, I am beginner... to learn: msc artificial intelligence distance learning Try to provide me good... intelligence distance learning". Also tell me which is the good training
distance learning masters in data science
distance learning masters in data science  Hi, I am beginner in Data...: distance learning masters in data science Try to provide me good examples or tutorials links so that I can learn the topic "distance learning masters
master data science distance learning
master data science distance learning  Hi, I am beginner in Data...: master data science distance learning Try to provide me good examples or tutorials links so that I can learn the topic "master data science distance
masters in artificial intelligence distance learning
masters in artificial intelligence distance learning  Hi, I am... for the tutorials to learn: masters in artificial intelligence distance learning Try...;masters in artificial intelligence distance learning". Also tell me which
distance learning data science masters
distance learning data science masters  Hi, I am beginner in Data...: distance learning data science masters Try to provide me good examples or tutorials links so that I can learn the topic "distance learning data science
data science degree distance learning
data science degree distance learning  Hi, I am beginner in Data...: data science degree distance learning Try to provide me good examples or tutorials links so that I can learn the topic "data science degree distance
ModuleNotFoundError: No module named 'djangorestframework-gis-distance'
ModuleNotFoundError: No module named 'djangorestframework-gis-distance' ...: ModuleNotFoundError: No module named 'djangorestframework-gis-distance' How to remove the ModuleNotFoundError: No module named 'djangorestframework-gis-distance'
ModuleNotFoundError: No module named 'gis-py-distance'
ModuleNotFoundError: No module named 'gis-py-distance'  Hi, My... named 'gis-py-distance' How to remove the ModuleNotFoundError: No module named 'gis-py-distance' error? Thanks   Hi, In your python

Ads