Thread: Nested If/Else?
View Single Post
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 06-25-2018, 07:58 PM

Quote:
Originally Posted by jkidd View Post
Hi chickentree -

I did everything that you suggested, as you can tell from this screenshot: https://image.ibb.co/nMUhzo/ifelse_2.jpg

If I enter a number under 21, the bouncer responds accordingly. If I enter the number 21 or a number over 21, the bouncer says "welcome to our exclusive club". If the user types in a number over 21, the bouncer is supposed to say that the user is too old.

I'm not sure what I'm doing wrong.
You are still not saving the user input in the age variable. This needs to be done before the if statement, please look at my example code again.

As it is now the user input is tested to see if it is less than 21, after that the user answer is thrown away and the value of Age ( which is now 0) is used in the enclosed if statement so it will never be more than 21.


Mark


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote