使用参数时找不到符号错误

时间:2019-01-22 02:34:45

标签: java

我正在用Java创建危险版本,我只是将答案方法输入到它们各自的问题方法中,并且在参数方面出现“找不到符号”错误。有人可以帮忙吗?

    public static void questions400opt1 ()
    {
      Random rndm = new Random();
      int randomQGenerator = 1 + rndm.nextInt(5);

     if(randomQGenerator == 1)
     {
       System.out.println("");
       System.out.println("QUESTION: chris pratt voices this character in the lego movie");
       answer400opt1q1(total, total2, total3);
     }
     else if(randomQGenerator == 2)
     {
       System.out.println("");
       System.out.println("QUESTION: anna and elsa are the main characters of this blockbuster film");
       answer400opt1q2(total, total2, total3);
     }


The actual answer400opt1q1 method looks like (snippet):

    public static void answer400opt1q1 (int total, int total2, int total3)
    {
      Scanner word = new Scanner(System.in);
      Scanner num = new Scanner(System.in);

      System.out.print("ANSWER:");
      String answer = word.nextLine();
      System.out.print("player, enter your buzzing number: ");
      int playerNumber = num.nextInt();

      if(playerNumber == 1)
      {
       if(answer.equalsIgnoreCase("emmett"))
       {
         total =+ 400;
         System.out.println("");
         System.out.println("correct!");
       }
       else if(!(answer.equalsIgnoreCase("emmett")))
       {
         total =- 400;
         System.out.println("");
         System.out.println("incorrect answer!");
      }
     }

1 个答案:

答案 0 :(得分:1)

questions400opt1()方法中,totaltotal2total3未声明为变量。使用前请先声明它们。