View Single Post
  #4 (permalink)  
Old 04-23-2008, 12:45 PM
SCS17 SCS17 is offline
Member
 
Join Date: Nov 2007
Posts: 20
SCS17 is on a distinguished road
I do see what you guys mean.. I actually know how to get the correct average using a for or a while loop but I just wanted to try it using a do-while.

I do see the mistake.. actually now I think of it, probably a do-while is not the best thing to use in these kind of things unless you wanna loop forever and have an if statement inside like Eranga did.

But isnt the do-while supposed to check the boolean condition in the while() before executing the body. ?? otherwise.. whats the use of using it.

So lets say I entered 1 the first time, then 1, then 1.. then the last time when I enter (-1).. the loop should check the boolean condition and determines what happens, so when I enter (-1), the loop should break.. you know I was thinkin that java will read the input and then jump to the while part to check the boolean condition.. thats what I was thinking!.

The flow of control here is kind of confusing.
I hope some of you guys can explain this a little bit if you dont mind.

Thanks alot.. appreciate it.

Last edited by SCS17 : 04-23-2008 at 12:51 PM.
Reply With Quote