该程序显示一个问题,用户输入数字 1 到 5。5 个用户的 5 个问题。但是,只要它是一个 Int,程序就不会识别一个好的输入或一个坏的输入。我必须输入很多次才能再次运行 Survey.presentQuestions() 。我不知道为什么。
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
Survey.presentQuestion(j, i);
do{
TempAns = in.nextInt();
while (!(in.hasNextInt()))
{
System.out.println("Please enter integer value from 1 to 5!");
in.next();
}
}while(TempAns >= 1 && TempAns <= 5);
Survey.ResultArray[i][j] = TempAns;
}
}