Hello, can someone help me on why my code keeps saying invalid method declaration? import java.util.Scanner; public class PillagaQuiroz_Derick_Project_05A    {    public static void main(String[] args)          {         double distance; // In meters          // Get the distance       distance = getDistance();       kilometers = distanceToKilometers();       inches = distanceToInches();       feet = distanceToFeet();             } // End main       getDistance();       public static void getDistance(double distance)       {          // string       double distanceInMeters;          // Get distance from user       System.out.println("Enter a distance (in meters):") ;       Scanner keyboard = new Scanner(System.in) ;       distance = keyboard.nextDouble() ;          // To not accept a negative input       while (distance < 0)          {          System.out.println("A negative number is not a valid input, please try again.");          getDistance();          }       }// End getDistance       public static void menu(double distance)       {             int selection;       System.out.println("Select one of the following choices:") ;         System.out.print("\n1.Convert to kilometers") ;                //for (int num = 0; num < salesStore1; num += 100)         //{         //    System.out.print("*") ; //Ex. output: **         //}         System.out.print("\n2.Convert to inches") ;         System.out.print("\n3.Convert to feet") ;         System.out.print("\n4.Quit the program") ;                         Scanner keyboard = new Scanner(System.in) ;         selection = keyboard.nextInt() ;                 if (selection==1)          {          distanceToKilometers(distance);          }          else if (selection==2)             {             distanceToInches(distance);             }          else if (selection==3)             {             distanceToFeet(distance);             }          else if (selection==4)             {             quitProgram();             }          else if (selection > 4 && selection < 0)             {             System.out.print("Error: Invalid choice. Please a number from 1-4.") ;             menu(distance);             }                }// End menu       public static void distanceToKilometers(double distance)       {             double kilometers;             kilometers = distance * 0.001;       System.out.print(distance + " = " + kilometers) ;             }// End distanceToKilometers          public static void distanceToInches(double distance)       {             double inches;             inches = distance * 39.37;       System.out.print(distance + " = " + inches) ;             }// End distanceToInches          public static void distanceToFeet(double distance)       {             double feet;             feet = distance * 3.281;       System.out.print(distance + " = " + feet) ;             }// End distanceToFeet          public static void quitProgram()       {                   System.out.print("Have a good day!") ;             }// End quitProgram    }//End conversionProgram

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello, can someone help me on why my code keeps saying invalid method declaration?

import java.util.Scanner;

public class PillagaQuiroz_Derick_Project_05A
   {
   public static void main(String[] args)   
      {
 
      double distance; // In meters
  
      // Get the distance
      distance = getDistance();
      kilometers = distanceToKilometers();
      inches = distanceToInches();
      feet = distanceToFeet();
     
      } // End main
  
   getDistance();
  
   public static void getDistance(double distance)
      {
  
      // string
      double distanceInMeters;
  
      // Get distance from user
      System.out.println("Enter a distance (in meters):") ;
      Scanner keyboard = new Scanner(System.in) ;
      distance = keyboard.nextDouble() ;
  
      // To not accept a negative input
      while (distance < 0)
         {
         System.out.println("A negative number is not a valid input, please try again.");
         getDistance();
         }
      }// End getDistance
  
   public static void menu(double distance)
      {
     
      int selection;
      System.out.println("Select one of the following choices:") ;

        System.out.print("\n1.Convert to kilometers") ;       
        //for (int num = 0; num < salesStore1; num += 100)
        //{
        //    System.out.print("*") ; //Ex. output: **
        //}
        System.out.print("\n2.Convert to inches") ;
        System.out.print("\n3.Convert to feet") ;
        System.out.print("\n4.Quit the program") ;
               
        Scanner keyboard = new Scanner(System.in) ;
        selection = keyboard.nextInt() ;
       
        if (selection==1)
         {
         distanceToKilometers(distance);
         }
         else if (selection==2)
            {
            distanceToInches(distance);
            }
         else if (selection==3)
            {
            distanceToFeet(distance);
            }
         else if (selection==4)
            {
            quitProgram();
            }
         else if (selection > 4 && selection < 0)
            {
            System.out.print("Error: Invalid choice. Please a number from 1-4.") ;
            menu(distance);
            }
        
      }// End menu
  
   public static void distanceToKilometers(double distance)
      {
     
      double kilometers;
     
      kilometers = distance * 0.001;
      System.out.print(distance + " = " + kilometers) ;
     
      }// End distanceToKilometers
     
   public static void distanceToInches(double distance)
      {
     
      double inches;
     
      inches = distance * 39.37;
      System.out.print(distance + " = " + inches) ;
     
      }// End distanceToInches
     
   public static void distanceToFeet(double distance)
      {
     
      double feet;
     
      feet = distance * 3.281;
      System.out.print(distance + " = " + feet) ;
     
      }// End distanceToFeet
     
   public static void quitProgram()
      {
           
      System.out.print("Have a good day!") ;
     
      }// End quitProgram
  
}//End conversionProgram

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education