Hi Campbell,
Thanks for the welcome and also for formatting my code and the feedback on comments
Yes, I have run the program myself a few times before posting it here.
There were 2 points from Mr.Curawn's requirement that must be honoured in the proposed solution.
1. The whole purpose of the while loop is to check whether the returned integer fetchSb has incremented or not and keep doing so until the increment has totaled 10. So, current can't just be incremented by 2 in each iteration.
2. When fetchsb (or the latest current value post increment) exatctly matches the target, then different set of statements should be executed i.e. printing "Click end" in this example.
While most of the answers tried to address point 2, I feel the point 1 is also crucial and can't be ignored. From the point 1, we can say the ultimate goal is not to solve the problem by using a loop (while or other loops) but instead while loop was used as just a means of solving it.
Hence, I feel, we dont need a loop here, because as we know, a loop will always evaluate the conditon only "after" each iteration and not automatically break/exit in the middle of one such iteration just because some operation resulted in reversing the condtion's trueness.
I think, this was the crux of the dilemma in Mr. Curawn's question, where in he was using an if (to evaluate the same loop conditon) within the loop.
As per point 1, as the variable is not always incremented and to simulate that uncertainty, I have used nextBoolean() of Random class in my solution. So, on different runs, we might see a slightly different output wherein the retry is suggested a few additional times at certain values.But, as in point 2, it exits and prints a different msg when the variable exactly matches the target value.
My solution could very well be wrong if my interpretation of the problem itself is incorrect. Would be better if Mr. Curwan gets to check and confirm this.