Alice Community Intro to Programming Using Alice

 Intro to Programming Using Alice
 gibs7usa Guest   Status: Posts: n/a Intro to Programming Using Alice - 04-12-2009, 08:43 PM I am working on "An Introduction to Programming Using Alice" Exercise 10 on Page 151: Creating a Guessing Game world I have to create a world that asks the user to guess a random number of the computer's choice. There are 2 characters in the world, one tells you if the number is too high and one tells you if the number is too low. The computer should keep asking you to guess until you guess the correct number. My problem is that it keeps asking me to guess a number even after I guess the correct number. I have to set up a sentinel loop so this doesn't happen, but I can't figure out how. I have reviewed the book, but maybe I am putting the wrong thing inside the While Tile Thanks!
 HisWorld Guest   Status: Posts: n/a 04-27-2009, 08:05 AM Since I don't have this book I can't be certain, however having programmed something simliar in other languages I believe all you need is an additional if-else statement inside your loop. I would think having three if else statements inside of one loop would be sufficient. One to tell user if to high, and one to tell if to low, both not breaking out of the loop, finally one that is just right and has a method call. A second solution would be to use a while statement such as while answer =! correct.answer{ } which would break the loop once a correct answer was given and go to your next line of code.

 Tags while tile sentinel loop

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge