int ID;
Scanner scan = new Scanner(System.in);
ID = Integer.parseInt(scan.nextLine());
do{
System.out.println("Improper EMPID, please reenter your EMPID.\n");
Scanner scan1 = new Scanner(System.in);
ID = Integer.parseInt(scan1.nextLine());
}
while (ID > 999999 && ID < 10000000);
return ID;
This is a function in my main code where I attempt to have the user enter a seven digit ID.
It's supposed to loop infinitely until the user enters seven digits, however will only loop through once then exits.
I have also done this with a while loop with the same results. Something I'm not seeing here?
Scanner scan = new Scanner(System.in);
int id = Integer.parseInt(scan.nextLine());
while (id >= 10000000 || id <= 999999);{
System.out.println("Please enter your EMPID\n");
id = Integer.parseInt(scan.nextLine());
}
return id;
My code now looks like this.
It will constantly loop without showing the print.