Results 1 to 5 of 5
Thread: Problem with Conversion Program
- 05-06-2011, 07:35 PM #1
Member
- Join Date
- May 2011
- Posts
- 1
- Rep Power
- 0
Problem with Conversion Program
Hey so im really new to java and I am having trouble with an assignment that converts meters to kilometers, inches, and feet based off of the users choice. Can anyone help with solving the errors::confused: Thanks
Here is what I got so far
import java.util.Scanner;
public class Program4RIT {
public static void main(String[] args){
double meters;
int decision;
meters = getInputLength();
}
public static int getInputLength(){
int meters;
Scanner keyboard = new Scanner (System.in);
System.out.println( "Enter a distance in meters" );
meters = keyboard.nextInt();
return meters;
}
{
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("Enter your choice :");
Scanner input;
int decision = input.nextInt();
if (decision == 1){}
}
public static int getKilometers(){
double meters;
showKilometers1(meters);
}
private static void showKilometers1(double meters) {
// TODO Auto-generated method stub
}
{
int decision1;
if (decision1==2){}
}
public static int getInches(){
double meters;
showInches(meters);
}private static void showInches(double meters) {
// TODO Auto-generated method stub
}
{
if (decision1 == 3){
}
public static int showFeet(){
double meters;
showFeet(meters);
}
while (decision < 4);
if ( decision == 4)
{
System.out.println(" Bye!");
}
public static void showKilometers(double meters){
}
{
double kilometers;
int meters;
kilometers =( meters /1000);
System.out.println( meters + "The distance in meters is " + kilometers + " kilometers " );
}
public static void showInches(double meters);
{
double inches;
double meters;
inches=( meters *39.3700787);
System.out.println( meters + "The distance in meters is " + inches + " inches " );
}
public static void showFeet(double meters)
{
double feet;
feet =( meters *3.280839895);
System.out.println( meters + "The distance in meters is " + feet + " inches " );
}
{
}
{
}
}
}
- 05-06-2011, 07:37 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Well, maybe, if we knew what the errors were.
-
Please
- Tell us what errors you are having posting the actual error messages themselves.
- Indicate which lines are causing which errors.
- Edit your post above and add code tags so that your code will be readable. The tag [code] goes above your code block and the tag [/code] goes below the code block.
Much luck and welcome to the forum!
- 05-06-2011, 09:07 PM #4
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
Wtf... your code makes no sense whatsoever.
Try using a switch statement for the input like so:
Etc.Java Code:Scanner scanner = new Scanner(System.in); int decision=scanner.nextInt(); switch(decision) { case 1: //kilometers /* CODE */ break; //end the case case 2: //inches /* CODE */ break; }
- 05-06-2011, 10:34 PM #5
Similar Threads
-
Binary-to-Decimal Conversion (Precision Problem)
By shadowfax57 in forum New To JavaReplies: 4Last Post: 09-07-2010, 09:00 AM -
Problem of conversion JFrame to Applet
By Rekuta in forum Java AppletsReplies: 9Last Post: 05-16-2010, 03:31 AM -
celsius to farenheit conversion program...
By andrewsx in forum New To JavaReplies: 3Last Post: 03-03-2010, 04:34 AM -
a simple conversion problem
By sweetjava in forum New To JavaReplies: 3Last Post: 07-20-2009, 06:34 AM -
Problem in TIFF Conversion
By lakshmipriyam in forum Advanced JavaReplies: 1Last Post: 08-09-2007, 10:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks