Alice Community How do I make an if/else equal yes?

 How do I make an if/else equal yes?
 HalBen18 Junior Member   Status: Offline Posts: 12 Join Date: Jan 2014 Location: Cedar Hill, TX How do I make an if/else equal yes? - 03-20-2014, 08:51 PM I have a program where a girl asks the user how many times they want her to spin. After that, she jumps up, spins that amount and then comes down. Then I ask the user if the want the program to repeat. I need help with if they input "yes" to have it run again. If they say no, she needs to say goodbye. I can't find a yes or no equation. Then I can't figure out how to use a loop to do this so that it will run continually as long as the user keeps entering "yes" at the end. Help please?
 Booleans
MrMoke
Senior Member

Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Booleans - 03-20-2014, 09:22 PM

The cool thing about Boolean variables is that they can only be one of two possibilities at any given time.
So, if you create a variable called something like "running" and make it "true", you can use it anywhere there is a true/false test.
If "running"
do something
else
do something else

OR
While "running"
do a bunch of stuff over and over
and change "running to false to stop the loop

See if you can modify this code to print "true" four times before printing "false".
Don't just add three more print lines.
Instead, create a numeric "counter" and add test logic to determine when to set "running" to "false". Just a few lines of code will let you print any number of trues.
Attached Images
 boolean.jpg (46.5 KB, 21 views)

Last edited by MrMoke; 03-21-2014 at 07:15 AM.

 if/else equal true
 levimrj Junior Member   Status: Offline Posts: 11 Join Date: Jan 2014 Location: Dallas, TX if/else equal true - 03-28-2014, 02:34 PM I did not know you could make a true false statement like that!! I just got through with my assignment of the spinning character and I used a 'while' statement. Not sure if the 'while' is preferable over the 'if/else' statement but I figured since I didn't have an 'else' for my character to do, I used the 'while' statement. Some of these assignments seem hard until I really start thinking about what I'm writing in the program and then it makes sense.
 It's called the Logical Thought Process
MrMoke
Senior Member

Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
It's called the Logical Thought Process - 04-10-2014, 03:24 PM

It's what programmers do

Click and Open the attached Movie
Attached Files
 Spinner.zip (19.96 MB, 6 views)

 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