public class homework8_2

  public static void main(String [] args)
  {

    Scanner keyboard = new Scanner(System.in);
     int selections = 0;
     DecimalFormat formatter = new DecimalFormat("#0.0000");
     do
     {

       showMenu();
        selections = keyboard.nextInt();
        System.out.println("please input the amount of meters");
        double meters = keyboard.nextDouble();
        if (selections == 1)
        {
          double kilometers; 
          kilometers = showKilometers(meters);
          System.out.println("Kilometers = " + kilometers);
        }
        else if (selections == 2)
        {
          double inches = 0;
          inches = showInches(meters);
          System.out.println("inches = " + inches);
        }
        else if (selections == 3)
        {
          double feet = 0;
          feet = showFeet(meters);
          System.out.println("Feets  = " + feet);
        }
     }while (selections != 4);
    }
    public static void showMenu()
    {
     System.out.println("METER CONVERSION");
      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("Please make the selection");
   }


  public static double showKilomters(double meters)
  {
    double kilometers = meters* 0.001;

  }
  public static double showInches(double meters)
  {
    double inches= meters * 39.37;

  }
  public static void showFeet(double meters)
  {
    double feet= meters * 3.2; 
  }

}

forgot to say but the error i get is

homework8_2.java:44: error: cannot find symbol
          kilometers = showKilometers(meters);
                       ^
  symbol:   method showKilometers(double)
  location: class homework8_2
homework8_2.java:56: error: incompatible types
          feet = showFeet(meters);
                         ^
  required: double
  found:    void
2 errors


I am new to java so i need some help

check line 47
public static double showKilomters(double meters)..spelling mistake

and the showFeet() function should return a double variable like this

public static void showFeet(double meters)
{
    double feet= meters * 3.2;
    return feet;
}

Edited 3 Years Ago by cool_zephyr

Comments
yes ... a method with return type void should return a double ..... did you read your textbook? do you know what void means?

The first one is simply a misspelling in the definition of the showKilometers() method.

The second is that you declared showFeet() ad type void, when it should in fact return a double.

On a related not, you need to have the actual return statements in the three 'show' functions:

  public static double showKilometers(double meters)
  {
    return meters * 0.001;

  }
  public static double showInches(double meters)
  {
    return meters * 39.37;

  }
  public static double showFeet(double meters)
  {
    return meters * 3.2; 
  }

HTH.

Okay thanks for the help, didn't realize i had some spelling issues and forgot to add a return. But now it works and is running like it is suppose to! thanks everyone

a remark on cool_zephyr's post:

public static void showFeet(double meters)
{
    double feet= meters * 3.2;
    return feet;
}

no ... this is not how it should be. this wouldn't even compile.
maybe like this:

public static double showFeet(double meters)
{
    double feet= meters * 3.2;
    return feet;
}

or something like:

public static void showFeet(double meters)
{
    double feet= meters * 3.2;
    System.out.println("feet = " + feet);
}

but not what was in that post.

This question has already been answered. Start a new discussion instead.