• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a loop.  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, after you input the first answer, and go through the other series of answers, I want to come back and ask the initial question again. Should this be nested? Where should I start?

 
Greenhorn
Posts: 24
Eclipse IDE Google App Engine Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume with while loop, and lets say you need to type 4 to exit.... something like this

WHILE input != 4 do
ask for input
do what is requested


this is first what came on my mind ..
 
Grant Gibson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Igor Mandic wrote:I assume with while loop, and lets say you need to type 4 to exit.... something like this

WHILE input != 4 do
ask for input
do what is requested


this is first what came on my mind ..


I inserted a while loop, and it just did one of the if statements continually. Should I put break after it? Or something like that?
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To learn about loops, see this tutorial: Control Flow Statements. Especially the pages The while and do-while Statements and The for Statement.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could make like this^^

 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be better if the instructions were repeated after each choice and also included instructions about how to exit.
I think a do/while loop would be better in this instance.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!