0% found this document useful (0 votes)
35 views3 pages

Journal Entry Unit 4 Lesson 8 Conditionals Make

Uploaded by

Kaito Isshiki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Journal Entry Unit 4 Lesson 8 Conditionals Make

Uploaded by

Kaito Isshiki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Unit 4 Lesson 8: Conditionals

Journal Entry – November 9

1. I had to create 5 variables


var day;
var age;
var discountCode;
var price;
var ticketText;

2. Then I created an onEvent for the orange


calculateButton and put the text “Create My Ticket” as
the text for this button

3. In the onEvent I had to put a local var to get the text


from the dayDropdown button

4. In the onEvent I also had to put a


second local var to get the number
from the ageDropdown button

5. In the onEvent I had to put a third local var to get the


text from the discountInput button

My code up to this point looked like


this:

6. I now must mention the FREEFRIDAY discount code in my code.

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.

The code looks something like this:

12. Finally, I must set the text to the textOutput box from the ticketText line (21). That code looks
like this:

My entire code for this APP looks like this:


Summary
This took me awhile to complete, but through trial and error, I finally got the code to work.

What was hard? Setting the code to line 21. I kept forgetting the quotation marks.

What I learned: to be patient and to read and re-read my code.

What I did NOT understand: I think I understood it all, it was just a matter of debugging my code as
I went along.

You might also like