“税不能解析为变量”

时间:2018-09-20 01:09:44

标签: eclipse

我正在调试中。该代码应该承担成本并计算新价格。我不确定我缺少什么。

    import javax.swing.JOptionPane;
        public class DebugTwo4 {
        public static void main(String[] args) { 

          String costString;
          /* added semicolon */
          double cost;
          final double TAX = 0.06;
          costString = JOptionPane.showInputDialog("Enter price of item you are buying", "Purchases",
             JOptionPane.INFORMATION_MESSAGE);
          cost = Double.parseInt(costString);
          JOptionPane.showMessageDialog(null,"With " + tax * 100 +
             "% tax,  purchase  is $" + (cost - cost * tax));
       }


}

1 个答案:

答案 0 :(得分:0)

Java区分大小写。

将“税”更改为“税”。

// old: JOptionPane.showMessageDialog(null,"With " + tax* 100 + "% tax,  purchase  is $" + (cost - cost * tax));
JOptionPane.showMessageDialog(null,"With " + TAX * 100 + "% tax,  purchase  is $" + (cost - cost * TAX));