You had the
getDouble method inside the
main method. This confuses the compiler.
Also, the type (string) in the
getDouble argument (string prompt) should be capitalized, viz, "String prompt".
This compiles okay:
package edu.uwec.cs.muellerzabel.conversion;
import javax.swing.JOptionPane;
public class Convert {
public static void main(String[] args) {
double dblUserInput = 0;
double dblEnglish = 0;
double dblFeet = 0;
double dblInches = 0;
dblUserInput = getDouble("Enter the number of meters you would " +
"like to convert to feet or inches.");
dblEnglish = dblUserInput * 39.37;
dblFeet = dblEnglish / 12;
dblInches = dblEnglish;
if (dblEnglish > 12){
JOptionPane.showMessageDialog(null, dblUserInput +
" meters is equal to " + dblFeet + " feet.");
} else {
JOptionPane.showMessageDialog(null, dblUserInput +
" meters is equal to " + dblInches + " inches.");
}
}
private static double getDouble(String prompt) {
double x = 0;
boolean done = false;
while (!done) {
try {
x = Double.parseDouble(JOptionPane.showInputDialog(prompt));
done = true;
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null,
"That wasn't a valid input. Please enter a number.");
}
}
return x;
}
}