0% found this document useful (0 votes)
674 views2 pages

Activity Guide - Conditionals Make - Unit 4 Lesson 8

The document provides instructions for an activity where students will code a movie ticket app that uses conditionals. It includes 4 steps: 1) Try out sample inputs to the app, 2) Plan the variables and conditional logic needed for the app, 3) Write the code for the app based on the plan, and 4) Submit the code and check it against a rubric. The app needs to determine ticket prices based on the day, age, and whether a discount code is used. Prices are $10 on weekends, $5 for ages 18 and under on weekdays, and free on Fridays with the "FREEFRIDAY" code.

Uploaded by

tamya
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)
674 views2 pages

Activity Guide - Conditionals Make - Unit 4 Lesson 8

The document provides instructions for an activity where students will code a movie ticket app that uses conditionals. It includes 4 steps: 1) Try out sample inputs to the app, 2) Plan the variables and conditional logic needed for the app, 3) Write the code for the app based on the plan, and 4) Submit the code and check it against a rubric. The app needs to determine ticket prices based on the day, age, and whether a discount code is used. Prices are $10 on weekends, $5 for ages 18 and under on weekdays, and free on Fridays with the "FREEFRIDAY" code.

Uploaded by

tamya
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/ 2

Unit 4 Lesson 8

Name(s)___Tamya Beasley____________________________________________ Period ______ Date _________

Activity Guide - Conditionals Make


Step 1 - Try the app
Try making tickets for different combinations of inputs. "dayD
"ageD
● Make a ticket for a weekend. "disco
ropdo
"calcu
● Make a ticket for a weekday (Monday - Friday) and someone 18 or
younger. ropdo
untIn
● Try the discount code "FREEFRIDAY" on a Friday. wn"
lateB
"ticke
wn"
Discuss with a Partner put"
utton"
tOutp
● What variables would you need to program this app?

ut"
● Where does this app use conditionals (if-statements)?

Step 2 - Plan
Variables: Fill in the table below for each variable you'll need to create.
Variable Name What the Variable Stores

age This represents the age of the person buying a ticket

discount This represents the “FREEFRIDAY” discount

day This represents the day of the week

price This represents the price of the ticket

Conditionals: Draw a flowchart that follows the rules below. There's more than one way to do it. Use the table to make
sure that your flowchart works for different combinations of age, day, and discount code.

● On the weekends ("Saturday" and "Sunday") everyone pays full price of $10
● On weekdays (Monday through Friday) if you are 18 years or younger you pay $5.
● If you use the discount code "FREEFRIDAY" on a Friday you get in for $0. No other discount codes will work
and the code only works on Fridays.

Age Day Discount Code Price If discount == “FREEFRIDAY” && day == “Friday”
18 Monday none $5
18 Saturday none $10
50 Monday none $10
50 Saturday none $10 True False
price = 0 age <= 18 && day != "Saturday") && day !=
18 Tuesday FREEFRIDAY $5
"Sunday"
50 Friday FREEFRIDAY $0
18 Friday FREE $5
50 Friday FREE $10 True False
price == price/2 price = 10

Computer Science Principles 1


Unit 4 Lesson 8
Step 3 - Write Your Code
● Write the code for the app, using your plan above and the comments provided in Code Studio to help
● Step You Can Follow
○ Create all the variables from your table above.
○ Give your variables a starting value using the assignment operator (=)
○ Create an event handler (onEvent) for the "calculate_button"
○ Inside the event handler start writing code for your conditional using your flowchart
○ Test your code as you go using the table below. At the end it should work for every combination of
outputs in the table on the first page.
○ Use your debugging skills to identify unexpected behavior and fix your program
○ Comment your code as you go, explaining what each event handler does
● Check the Help & Tips tab for ideas about Programming Patterns you can use
● Extension Ideas
○ Add another discount code for a different day of the week or age range
○ Make guests 65 and older always pay $5 unless they use a discount code

Step 4 - Submit
Before you submit, check the rubric below to make sure your program meets the requirements of the task.

Category Extensive Evidence Convincing Limited Evidence No Evidence


Evidence

Input onEvents are created onEvents are created onEvents are created onEvents are not
for all the required for most of the for some of the created for any
inputs. inputs. inputs. inputs.

Storage: Variables Variables are created Most information is Some information is There are no
and appropriately stored in a variable stored in a variable variables which store
used for all pieces of and appropriately and appropriately the necessary
information used in updated throughout updated throughout information for the
the app. the app. the app. app to work correctly.

Processing: The code correctly The code correctly The code correctly The code does not
Conditional Logic determines the price determines the price determines the price correctly determine
for all combinations for most but not all for some but not all the price for any
of inputs (age, price, combinations of combinations of combination of inputs
discount code). inputs (age, price, inputs (age, price, (age, price, discount
discount code). discount code). code).

Code: Output The screen correctly The screen displays The screen displays The screen does not
displays the day, most but not all some but not all correctly display any
age, and price of the information correctly information correctly information in the
ticket. in the ticket. in the ticket. ticket.

Code runs without No errors are present On or two errors are Three or four errors More than four errors
errors. in the required code. present in the are present in the are present in the
required code. required code. required code.

Coding Comments Comments are used Comments are used Comments are used Comments are not
to correctly explain to explain the to explain the present.
the purpose and purpose and function purpose and function
function of all of most onEvents of some onEvents
onEvents and and conditional logic. and conditional logic.
conditional logic.

Computer Science Principles 2

You might also like