Quote:
Originally Posted by jkidd
Hey guys -
I am working on an assignment that requires me to have a bouncer ask for the user's age. If the user is below 21, they don't get in. If the user is above 21, they're too old. If the user is indeed 21 years old, they get into the bar.
I have tried every combo that I can think of, and have read the class textbook, but can't make it work. Click on the following link to see a screenshot of my method in Alice: https://image.ibb.co/hyYpuo/ifelse.jpg
Any help or advice would be great!
Thanks.
|
You have two problems with your code:
- age is set to 21 and never changed.
- The if statements need to be nested.
What you need is to first set Age to the users input and then put one if statement inside the other
Code:
Age=0
Set Age to ask user for a number
If Age < 21 Then
// do too young stuff
else
If Age > 21 Then
//do too old stuff
else
// The user is not too young or too old
Hope this helps