Variable not equal to 0
1 Attachment(s)
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! |
variable equal to 0
1 Attachment(s)
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 |
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. Mark |
Thank you both for your help! I wasn't sure how to use that logic until I saw the "while" command. Thanks again!
|
All times are GMT -5. The time now is 01:08 AM. |
Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.