Alice Community Loop While If/Else Lab2

 Loop While If/Else Lab2
 Derrick James Guest   Status: Posts: n/a Loop While If/Else Lab2 - 04-09-2009, 07:04 AM First off I think Im starting to have fun with this now. Second there a few ways to achieve the same ultimate goal as far as having the program start again if answer was yes. I immediatley thought of (if/else) : if \askuserfor data string\ = Yes; yes;YES etc.(Nested) Else (myfirstworld) which called to everything. Which would work but no loop like the assignment called for. The next step was to use variables to act as on or off 0 or 1 which could then be set as the number of times to loop (myfirstworld). not really sure if thats what was called for but I made it work depending on the outcome of the if/else statement. I attempted to go further by allowing for typos or if the user said no No or NO. I was getting close but I just had too many loops and if/else statements so i deleted them. I'm sure that there was a simpler solution.
 HisWorld Guest   Status: Posts: n/a 05-04-2009, 11:02 PM try comparing it to a list with your different spellings, this should simplify things considerably
 Compare to list?
 Derrick James Guest   Status: Posts: n/a Compare to list? - 05-07-2009, 11:15 AM How would I do that? Is this the same thing as lists and arrays. Just thinking here but could i make a variable for each of no No NO or anything for that matter and then create if/else that is or is not equal to the variables as an array or list?
 HisWorld Guest   Status: Posts: n/a 05-08-2009, 10:41 AM You could make a seperate variable of type string and compare them, I havn't verified this in Alice, but I have defiently done this in Java. I think the equivalent in java is strcomp("....","....") but in alice probably just ==. Making a list would be simpilier and prefill it will the different no's Lists, array's, stacks, file's are all different way's of organizing a group of usualy related data. Lists and array's are nice because you can usually access any part of the list, In stacks "FILO" only the last item of data stored can be accessed , in file"FIFO", only the first one stored. scott300 has posted a game that utilizes lists in alice Last edited by HisWorld; 05-08-2009 at 10:42 AM. Reason: inserted hyperlink

 Tags loop while if/else lab2

 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