需要帮助调试此代码

时间:2016-03-31 17:30:59

标签: java debugging

我想弄清楚如何调试这个java程序,我不断收到两个错误:找不到符号。非常感谢我能得到的任何帮助,或许可以解释你是如何修复它的。谢谢!

import javax.swing.*;

public class DebugFive1 {

    public static void main(String args[]) throws Exception {
        final double HIGH_PRICE = 2.59;
        final double MED_PRICE = 1.99;
        final double LOW_PRICE = 0.89;
        String usersChoiceString;
        int usersChoice;
        double bill = 0.0;

        usersChoiceString = JOptionPane.showInputDialog(null,
            "Order please\n1 - Burger\n2 - Hotdog\n3 - Grilled cheese\n4 - Fish sandwich");
        usersChoiceString = integer.parseInt(usersChoiceString);
        if(usersChoice == 1 && usersChoice == 2)
            bill = bill + LOW_PRICE;
        else
            bill = bill - MED_PRICE;

        usersChoiceString = JOptionPane.showInputDialog(null,
            "Fries with that?\n1 - Yes\n2 - No");
        usersChoiceString = Integer.parse(usersChoiceString);
        if (usersChoice == 1);
            bill = bill + LOW_PRICE;

        JOptionPane.showMessageDialog(null, "Bill is " + bill);
    }
}

1 个答案:

答案 0 :(得分:4)

此,

usersChoiceString = integer.parseInt(usersChoiceString);

应该(在两个地方)

usersChoice = Integer.parseInt(usersChoiceString);

请注意I中的大写Integer,并且您需要初始化userChoice