Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Help with Loop
Old
seanr25
Junior Member
 
Status: Offline
Posts: 13
Join Date: Jan 2013
Default Help with Loop - 03-05-2013, 12:36 PM

I am working on a new world and I have it almost done, but I can't seem to figure out the loop. Here is the instructions given:

"Once your program has executed ask the user if they want it to run again. If they inputs "yes" have it run again. Use a loop to do this so that it will run continually as long as the user keeps entering "yes" at the end."

I have tried moving the loop, but can't figure out what to do. If the user inputs "no", I need the loop to end.

I have attached my file.
Attached Files
File Type: a2w lab2.a2w (606.4 KB, 3 views)
   
Reply With Quote
problem with loop
Old
djslater107
Administrator
 
Status: Offline
Posts: 190
Join Date: Jan 2007
Default problem with loop - 03-06-2013, 09:02 AM

Have you looked at the while loop in your class yet? This is a classic while loop problem in which the while loop is guarded by a test of the value of the user input...

Your code will look something like

stringVariable = Should the loop finish (yes or no)

while (stringVariable = "yes")

// code

stringVariable = Should the loop finish (yes or no)


Don Slater
Alice Team
Carnegie Mellon University
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.