2016-03-31 17 views
-1

このJavaプログラムをデバッグする方法を理解しようとしていますが、2つのエラーが続いています。どのようにあなたがそれを修正しようとしたかについての説明を私が得ることができるどんな助けにも感謝します。ありがとう!このコードのデバッグを手助けする必要があります

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); 
    } 
} 
+2

コンパイラは、行番号とエラーが発生した場所を示す小さなマーカーを出力します。あなたの質問に**完全な**エラーテキストを含めてください。 –

答えて

4

これ、

usersChoiceString = integer.parseInt(usersChoiceString); 

usersChoice = Integer.parseInt(usersChoiceString); 

注資本IntegerI(両方の場所に)あるべき、とあなたはuserChoiceを初期化する必要があること。

+0

こんにちはエリオット。私は先に進み、小文字iを大文字に変更しました。今度はエラーが発生します:互換性のない型:intを文字列に変換できません。 – Nunzlol

+2

@Nunzlol 'usersChoiceString'ではなく' userChoice'に割り当てます。 –

+0

Integer.parse(usersChoiceString);このメソッドはIntegerクラスには存在しませんでした。 Integer.parseIntメソッド – RamPrakash