这是我的代码。我需要 wordOfTheDay 和答案保持不变。我需要用户输入“今天的单词是什么”和“3 * 8 的答案是什么”的答案,根据他们的答案,它要么被接受为正确答案,要么被拒绝,然后他们再试一次。我不断收到此编译器错误
错误:无法为最终变量 wordOfTheDay 赋值错误:无法为最终变量答案赋值
//The word of the day is Kitten
import java.util.Scanner;
public class SchmeisserKLE41 {
public static final Scanner input = new Scanner(System.in);
public static final String wordOfTheDay = "Kitten";
public static final int answer = 24;
public static void main(String[] args) {
int attempts = 3;
System.out.printf("Please enter the word of the day:");
wordOfTheDay = input.nextLine();
do{
-- attempts;
if(attempts == 0){
System.out.printf("Sorry! You've exhausted all your attempts!");
break;
}
System.out.printf("Invalid! Try again %d attempt(s) left.", attempts);
wordOfTheDay = input.nextLine();
}
while(!wordOfTheDay.equals("Kitten"));
System.out.printf("\nWhat is the answer to 3 * 8?");
answer = input.nextInt();
System.exit(0);
}
}