Journal Entry Unit 4 Lesson 8 Conditionals Make
Journal Entry Unit 4 Lesson 8 Conditionals Make
7. I used within the onEvent, the IF statement to have it say, “if the discountCode equals
“FREEFRIDAY” and the day equals “Friday”, then the price is 0”. So, when I translate that statement
into code, it looks like this:
8. Now I add an else If statement to translate this statement, “else if the day equals “Saturday” or
the day equals “Sunday”, then the price is 10”. The code for that looks like this:
9. Now I must check the age of the person purchasing a ticket. I add an else if statement to translate
this statement, “else if the age is less than or equal to 18, then the price is 5”. The code for that
looks like this:
10. Finally, the last statement in this onEvent as an else statement is to translate, “else the price is
10”. That code looks like this:
11. I now create local var in the onEvent to say, “the ticketText equates to “Day: “ plus day plus
add a new line for the “\nAge: “ plus the age plus add a new line for the “\nPrice: $“ plus price”. The
result of this will be placed in the Ticket Text Box when the information is input by the user.
12. Finally, I must set the text to the textOutput box from the ticketText line (21). That code looks
like this:
What was hard? Setting the code to line 21. I kept forgetting the quotation marks.
What I did NOT understand: I think I understood it all, it was just a matter of debugging my code as
I went along.