<分区>
我正在编写一个非常简单的程序,我从用户那里得到 3 个整数,我想检查以确保它们都是整数,然后再将它们存储到单独的变量中进行处理。我使用的检查适用于第一个输入,但失败并在后两个输入上引发异常。
boolean properInt = scanner.hasNextInt();
int largest = Integer.MAX_VALUE;
boolean anError = false;
while(properInt=false){
anError=true;
System.out.println("Invalid number...whole numeric values only");
}
while(properInt =true){
int a= scanner.nextInt();
System.out.println("you entered "+ a);
int b = scanner.nextInt();
System.out.println("you entered "+ b);
int c= scanner.nextInt();
System.out.println("you entered "+ c);