In the very last method below
import javax.swing.JOptionPane; public class program08 { public static void main(String[] args) { String getWeightString = JOptionPane.showInputDialog(null, "Enter the weight of the package"); double getWeight = Double.parseDouble(getWeightString); String handling = JOptionPane.showInputDialog(null, "Would you like Special handling? Enter 'Y' for yes."); char handlingChar = handling.charAt(0); String insurance = JOptionPane.showInputDialog (null, "Would you like insurance? Enter 'Y' for yes."); char insuranceChar = insurance.charAt(0); JOptionPane.showMessageDialog(null, "The total cost is" + ""); } public static double price(double getWeight) { double price; if (getWeight <= 2.00) price = 1.00; else if (getWeight > 2.00 && getWeight < 5.00) price = 2.00; else price = 4.00; return price; } public static double handlingPrice(char handlingChar) { double handlingPrice =0; if (handlingChar == 'Y' || handlingChar == 'y') handlingPrice = 5.00; return handlingPrice; } public static double insPrice(char insuranceChar) { double insPrice = 0; if (insuranceChar == 'Y' || insuranceChar == 'y') String insPriceString = JOptionPane.showInputDialog(null, "How much insurance would you like?"); insPrice = Double.parseDouble(insPriceString); insPrice += insPrice * 0.10; return insPrice; } }
At the line that reads "String insPriceString = JOptionPane.showInputDialog"
I get a warning that reads "Variable declaration not allowed here"
The assignment requires that the variable for the amount of insurance the user wants, if they want insurance, to be declared in a different method, not the main method.