我循环了五次并使用 util.Scanner 获取用户输入,我被困在我必须提示用户正确输入的部分,以及何时给出正确的输入并将其存储在数组中。然后循环继续。
while(a<5){
Scanner input = new Scanner(System.in);
System.out.println("Please enter the value: ");
int x = input.nextInt();
//what code should be added here to prompt user if input is not in 1-10
//and after checking only, the value should be stored in the array
userInputs[a] = x;
a++;
}
翻过高山走不出你
胡说叔叔
相关分类