Alice Community  

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

Thread Tools Display Modes
Variable not equal to 0
Junior Member
Status: Offline
Posts: 2
Join Date: Jan 2013
Default Variable not equal to 0 - 01-20-2013, 08:54 PM

Hi all,

I'm very new to programming and I have a course assignment wherein I need to have an error message appear if the user input is equal to zero. I've attached the file with the assignment completed, but I can't figure out how to use the alice interface to continue asking for the speed and distance variables if the user enters 0.

Help! And thanks in advance for your expertise!
Attached Files
File Type: a2w Hana.a2w (617.7 KB, 1 views)
Reply With Quote
variable equal to 0
Status: Offline
Posts: 180
Join Date: Jan 2007
Default variable equal to 0 - 01-21-2013, 09:18 AM

Set up a while loop... Assume you have a distance variable and a speed variable... Also comparing a variable for equality to zero is very difficult when dealing with real numbers, and so I am going to assume a minimum speed and minimum distance value that the user has to enter.

while (either speed < 1 or distance < 1 or both)
ask user for speed
ask user for distance

The functions and operators you are looking for are in world functions tab

See the attached screen shot
Attached Images
File Type: jpg mimimumValue.jpg (12.7 KB, 14 views)

Don Slater
Alice Team
Carnegie Mellon University
Reply With Quote
Super Moderator
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 01-21-2013, 05:20 PM

You need to ask the user for a number.
Look at World->function-> ask user (just under string functions.)

Judging from what is there already, adding this should not be a problem.

Reply With Quote
Junior Member
Status: Offline
Posts: 2
Join Date: Jan 2013
Default 01-21-2013, 08:23 PM

Thank you both for your help! I wasn't sure how to use that logic until I saw the "while" command. Thanks again!
Reply With Quote

Thread Tools
Display Modes

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 ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.