• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need to convert from while loop to for loop  RSS feed

 
Dan Good
Ranch Hand
Posts: 49
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there, my buddy asked me to help him convert this program from a while loop to a for loop. I'm stuck , can anyone check it out for me? Please note that it's pretty buggy right now...

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well a for loop is just a while loop with the initialisation, condition check and variable modification combined.
So the initialisation code is on line 21, the condition check is on line 24 and the variable modification is on line 44.
So what problem (other than the fact you are doing an assignment rather than a comparison on line 44) are you having ?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan Good wrote:Hey there, my buddy asked me to help him convert this program from a while loop to a for loop. I'm stuck

Unsurprising, as the while condition (at least as you posted it) is invalid.

Can you show us what it should have been?

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!