这是我的代码:
//DebugTwo4.java
import javax.swing.JOptionPane;
public class DebugTwo4
{
public static void main(String[] args)
{
String costString;
double cost;
double tax = 0.06;
costString = JOptionPane.showInputDialog(null,
"Enter price of item you are buying", "Purchases",
JOptionPane.INFORMATION_MESSAGE);
cost = Double.parseDouble("cost");
JOptionPane.showMessageDialog(null,"With " + tax * 100 + "% tax, purchase is $" + cost + cost * tax);
System.exit(0);
}
}
并且错误消息是:线程“main”中的异常 java.lang.NumberFormatException:对于输入字符串:“cost” at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1241) at java.lang.Double.parseDouble(Double .java:540) 在 DebugTwo4.main(DebugTwo4.java:16)