Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Reply
 
Thread Tools Display Modes
Assignment 5 - nested If statements
Old
lucyrn99
Member
 
Status: Offline
Posts: 23
Join Date: Aug 2016
Location: Dallas TX
Default Assignment 5 - nested If statements - 10-05-2016, 11:13 AM

Yikes, I had trouble trying to get the concept of how my program would need to do a different action based on one of THREE different answers!

It was easy to understand how to do actions based on two different answers, because that a simple true/false or if/else choice.
I kept rereading the text, watching various youtube videos, and experimenting with my animation, until I finally had an 'aha' moment.

In order to get my program to work correctly, I created one variable to ask the user to input an age. Then I used that variable in the first if/else statement, for the path age is > 21, so user is too old to enter the club.
I then dragged in a second if/else statement, and repeated the process of using the variable, except this time the path was 'age is < 21, so user is too young'.
Then I dragged in a 3rd if/else statement, this time for the path age = 21, so user can enter the club.

The mistake I had been making in the beginning, was trying to make all three of the paths work, via only TWO if/else statements.
Once I figured out that I needed a separate if/else for EACH path, it was easy peasy!
   
Reply With Quote
Old
bodyjohn
Member
 
Status: Offline
Posts: 28
Join Date: Oct 2018
Default 12-13-2018, 10:34 AM

Quote:
Originally Posted by lucyrn99 View Post
Yikes, I had trouble trying to get the concept of how my program would need to do a different action based on one of THREE different answers!

It was easy to understand how to do actions based on two different answers, because that a simple true/false or if/else choice.
I kept rereading the text, watching various youtube videos, and experimenting with my animation, until I finally had an 'aha' moment.

In order to get my program to work correctly, I created one variable to ask the user to input an age. Then I used that variable in the first if/else statement, for the path age is > 21, so user is too old to enter the club.
I then dragged in a second if/else statement, and repeated the process of using the variable, except this time the path was 'age is < 21, so user is too young'.
Then I dragged in a 3rd if/else statement, this time for the path age = 21, so user can enter the club.

The mistake I had been making in the beginning, was trying to make all three of the paths work, via only TWO if/else statements.
Once I figured out that I needed a separate if/else for EACH path, it was easy peasy!
great!
   
Reply With Quote
Old
Amzoun95
Junior Member
 
Status: Offline
Posts: 4
Join Date: Feb 2019
Location: alger
Default 10-11-2019, 09:52 AM

Once you pass a conditional statement then you've passed it until you get to it again.











Dafont Showbox Adam4adam

Last edited by Amzoun95; 10-12-2019 at 07:36 PM.
   
Reply With Quote
Reply

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