I've written a generalized inputDimension method that takes two parameters: a String that has one of the two values “length” or “width”, and an integer that can has the values 1 or 2, representing the pizza number. I have to implement this method, which I've done by creating the variable 'dimension.' But now I have to call it, as I did the first one: firstLength = inputDimension(“length”, 1);. But, I keep getting an error about parse. It reads:

. Any help would be greatly appreciated, as I'd like to learn how to properly execute it.Exception in thread "main" java.lang.NumberFormatException: empty String

at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)

at java.lang.Double.parseDouble(Unknown Source)

at edu.uwec.cs.jimeneam.lab5.Lab5Start.main(Lab5Start.java:37)

Code:package edu.uwec.cs.jimeneam.lab5; import javax.swing.JOptionPane; public class Lab5Start { public static void main (String [] args) { // --- general variables String inputString = ""; // input string for variables String outputString = ""; // output string for message dialog char continueChar = ' '; // character to hold 'Y' to continue or 'N' to stop // --- variables for first pizza double firstLength = 0.0; // length of first pizza if rectangular double firstWidth = 0.0; // width of first pizza if rectangular double firstArea = 0.0; // area of first pizza double firstCost = 0.0; // cost of first pizza double firstCostPerArea = 0.0; // cost per unit area of first pizza // --- variables for second pizza double secondLength = 0.0; // length of second pizza if rectangular double secondWidth = 0.0; // width of second pizza if rectangular double secondArea = 0.0; // area of second pizza double secondCost = 0.0; // cost of second pizza double secondCostPerArea = 0.0; // cost per unit area of second pizza // initialize to go through loop first time continueChar = 'Y'; // --- main processing loop while (continueChar != 'N') { // get the length and width of the first pizza firstLength = inputDimension("length", 1); //inputString = JOptionPane.showInputDialog(null, "Enter the length of the first pizza in inches"); firstLength = Double.parseDouble(inputString); firstWidth = inputDimension("width,", 1); //inputString = JOptionPane.showInputDialog(null, "Enter the width of the first pizza in inches"); //firstWidth = Double.parseDouble(inputString); // get the cost of the first pizza inputString = JOptionPane.showInputDialog(null, "Enter the cost of the first pizza"); firstCost = Double.parseDouble(inputString); // get the dimension(s) of the second pizza secondLength = inputDimension("Length", 2); secondLength = Double.parseDouble(inputString); secondWidth = inputDimension("Width", 2); secondWidth = Double.parseDouble(inputString); //inputString = JOptionPane.showInputDialog(null, "Enter the length of the second pizza in inches"); //secondLength = Double.parseDouble(inputString); //inputString = JOptionPane.showInputDialog(null, "Enter the width of the second pizza in inches"); //secondWidth = Double.parseDouble(inputString); // get the cost of second pizza inputString = JOptionPane.showInputDialog(null, "Enter the cost of the second pizza"); secondCost = Double.parseDouble(inputString); // calculate the area of the first pizza, and format that area firstArea = firstLength * firstWidth; firstArea = ((int)(firstArea * 100)) / 100.0; // calculate the area of the second pizza, and format that area secondArea = secondLength * secondWidth; secondArea = ((int)(secondArea * 100)) / 100.0; // calculate the cost per area of the first pizza, and format that cost per area firstCostPerArea = firstCost / firstArea; firstCostPerArea = ((int)(firstCostPerArea * 10000)) / 10000.0; // calculate the cost per area of the second pizza, and format that cost per area secondCostPerArea = secondCost / secondArea; secondCostPerArea = ((int)(secondCostPerArea * 10000)) / 10000.0; // initialize the output string outputString = ""; // append the information for the first pizza to the output string outputString += "\n First pizza: "; outputString += " Rectangle with length " + firstLength + " inches, width " + firstWidth + " inches"; outputString += ", Area of " + firstArea + " sq. inches, Cost of $" + firstCost + ", Cost per square inch of $" + firstCostPerArea; // append the information for the second pizza to the output string outputString += "\n Second pizza: "; outputString += " Rectangle with length " + secondLength + " inches, width " + secondWidth + " inches"; outputString += ", Area of " + secondArea + " sq. inches, Cost of $" + secondCost + ", Cost per square inch of $" + secondCostPerArea; // generate and append a comparison string to the output string if (secondCostPerArea < firstCostPerArea) { outputString += "\n Pizza 2 is a better value"; } else if (firstCostPerArea < secondCostPerArea) { outputString += "\n Pizza 1 is a better value"; } else { outputString += "\n Pizza 1 and Pizza 2 are of equal value"; } // output the output string to a message window JOptionPane.showMessageDialog(null, outputString); // ask the user if they want to continue inputString = JOptionPane.showInputDialog(null, "Do you want to continue? Enter Y to continue, N to quit"); continueChar = inputString.charAt(0); while (continueChar != 'Y' && continueChar != 'N') { inputString = JOptionPane.showInputDialog(null, "Do you want to continue? Enter Y to continue, N to quit"); continueChar = inputString.charAt(0); } } // end - while loop } // end - main method // other methods go here // method to input a dimension in general public static double inputDimension(String dimensionName, int pizzaNumber) { // declare local variables for an input string and the dimension as a general value String inputString = ""; double dimension = 0.0; // display an input box to get the "dimensionName" dimension for pizza "pizzaNumber" inputString = JOptionPane.showInputDialog(null,"Enter the " + dimensionName + " of pizza " + pizzaNumber + ":"); // parse that input string into the dimension variable dimension = Double.parseDouble(inputString); // return the dimension return dimension; } // method to calculate area of pizza } // end - class Lab5