I am very new to programming and am really struggling with Java. I'm currently working on the below code, but when I compile the program, I'm getting several messages referring to multiple lines in my code, all stating things like the following:
C:\Users\Heather\Documents\HACH5_8.java:111: cannot find symbol
symbol : variable showFeet
location: class HACH5_8
displayFeet(Meters, showFeet);
Here is my code:
// import java statements here
import java.util.Scanner; // Importing the Scanner class
import java.io.*; // Importing the file I/O class
import java.text.DecimalFormat; // Importing the DecimalFormat class
import javax.swing.JOptionPane; // Importing the JOptionPane class
// Begin class HACH5_8.java
public class HACH5_8
{
public static void main(String[] args)
// Begin main
{
double meters = 0; // To hold number of meters
double kilometers = 0; // To hold number of kilometers
double inches = 0; // To hold number of inches
double feet = 0; // To hold number of feet
// Get the number of meters
meters = getMeters();
// Convert the number of meters to kilometers using kilometers = meters * 0.001
showKilometers = meters * 0.001;
// Convert the number of meters to inches using inches = meters * 39.37
showInches = meters * 39.37;
// Convert the number of meters to feet using feet = meters * 3.281
showFeet = meters * 3.281;
// Display number of kilometers
displayKilometers(Meters, showKilometers);
System.exit(0);
// Display number of inches
displayInches(Meters, showInches);
System.exit(0);
// Display number of feet
displayFeet(Meters, showFeet);
System.exit(0);
// End main
}
public static double getMeters()
{
String input; // To hold input
double numberMeters; // To hold meters
// Allow user to enter the number of meters
input = JOptionPane.showInputDialog(
"This program converts measurements\n" +
"in meters to kilometers, meters to\n" +
"inches, and meters to feet. Enter\n" +
"the number of meters.");
// Convert the input to a double
numberMeters = Double.parseDouble(input);
// Return the number of meters
return numberMeters;
}
// Allow user to convert to kilometers using kilometers = meters * 0.001
public static double showKilometers(double numberMeters)
{
return numberMeters * 0.001;
}
public static void displayResults(double numberMeters, double showKilometers)
{
JOptionPane.showMessageDialog(null,
meters + " meters equals " +
kilometers + " showKilometers.");
}
// Allow user to convert to inches using inches = meters * 39.37
public static double showInches(double numberMeters)
{
return numberMeters * 39.37;
}
// Display results of inches
public static void displayResults(double numberMeters, double showInches)
{
JOptionPane.showMessageDialog(null,
meters + " meters equals " +
inches + " showInches.");
}
// Allow user to convert to feet using feet = meters * 3.281
public static double showFeet(double numberMeters)
{
return numberMeters * 3.281;
}
// Display results of feet
public static void displayResults(double numberMeters, double showFeet)
{
JOptionPane.showMessageDialog(null,
meters + " meters equals " +
feet + " showFeet.");
}
// End public class
}
If someone could help me, I would greatly appreciate it!