Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
Members have full access to the forums. Advertisements are removed for registered users.
Encouraging you (and showing you how) to think through solving this yourself.
Problem statement: It (the second loop) works the first time but when it comes to that point again after looping it won't loop anymore.
Inspect the code with the purpose of the second while loop in mind, answer the following questions:
1. It is supposed to loop when . . . . ? (answer the question - it's your code, you should know - the answer could even be a code comment).
2. So the loop control variable, loop2, should be <blank> when the loop should execute and <blank> when the loop should not execute. (fill in the <blank>s with the correct answer.)
3. When the loop runs and correct answers are given, the loop control variable, loop2, is set to <blank>. (fill in the <blank> with the correct answer.)
4. Considering the answer to number 3, what must happen in order for the loop to run again?
5. Considering the answer to number 4, what is the fix for the stated problem, "It (the second loop) works the first time but when it comes to that point again after looping it won't loop anymore?"