0
How to perform non-constant tasks within a while loop?
I am a beginner and I am trying to make a simple game where the user adds as many sets of two random numbers as they can within a given time frame. I have a while loop that counts down an integer X to zero. I want it so that as long as X > 0, I can give two random numbers, wait for a response, and repeat that process indefinitely until the timer is up. If I put the user.Input inside the while loop it will just repeat constantly and not actually let any input. How do I allow both timer and prompt to work?
5 ответов
0
Are you saying your scanner only accepts input once?
0
The scanner won’t accept any input because it is constantly trying to activate
0
It should pause the program to receive input. Please describe how you implemented it & which method you used to get the input.
0
Scanner response = new Scanner(System.in)
int r = response.nextInt();
Then I see if r = x + y
I put all of this directly inside the brackets of the while loop
0
There really is no reason why it should not work, perhaps examine your loop condition.