Scanner user input not working in conjunction with while loop.
I'm sure I'm doing something completely idiotic but this is stumping me. I'm having the same issue with another program and have no clue where to go from here.
Code:
Scanner s = new Scanner(System.in);
System.out.print(string1);
while(s.nextInt() < 10)
System.out.print(string2);
int n = s.nextInt();
When I comment out the while loop it works perfectly. With the while loop active, if I enter a number that shouldn't activate it, string2 is not printed but I'm given a second Scanner input box that shouldn't be there. If I do trigger the while loop, it prints string2 but then the same problem - it gives me a second, unnecessary Scanner input box.
Can anyone help me? Please!
Thanks!
-Nadz