AP COMP - U4L2 Activity Guide
AP COMP - U4L2 Activity Guide
Directions: Use this activity guide to record your thoughts and responses to the prompts, all
marked by bullet points below.
Level 1
Temperature
____________________________________________________________
Level 2
Complete the following prompts for both sections of the code
Lines 1-12
● Option 1- Explain what the section does out loud to a partner
● Option 2- write out explaining what the sections are doing
The down arrow button is pressed. When you press the down arrow
button, the temperature drops by one degree, the temperature is
displayed in Fahrenheit, a sound is played, and a text called
"temperatureText" is displayed.
● Call out any lines of code you thought were interesting or confusing
Lines eight and nine were interesting. Lines two and three are confusing.
Lines 14-21
● Option 1- Explain what the section does out loud to a partner
● Option 2- write out explaining what the sections are doing
The down arrow button is pressed. When you press the down arrow
CSP U4L2 Variables Investigate Activity Guide
____________________________________________________________
Level 3
● How do you think Math.round works?
● Try deleting Math.round in lines 3, 15, and 28. What happens? Add it back in.
We start to get the decimal values
● Delete the space in between the quotation marks and the letter "F" in line 4.
How does this change what is displayed on the screen?
It deletes the space between the number and F, they get squished
together.
____________________________________________________________
Level 4
● What new information is being stored?
Your name gets saved after you type it in and click login. When you enter
the new screen it says “Hiyourname”
____________________________________________________________
Level 5
Investigate the code for this new version of the Thermostat App.
● What’s code has been changed?
There is another home screen added where it asks for your name. There
is an exclamation mark after your name.
CSP U4L2 Variables Investigate Activity Guide
● What's happening on line 40? Hover over the getText() block in the toolbox
to read its documentation.
Concatenation is happening meaning two texts are being together.
● Using concatenation, add an exclamation point "!" to the end of the string
stored in userName so the following is displayed:
____________________________________________________________
Counter Pattern with Event
The Counter Pattern with Event is a common pattern for updating variables that you will use in
making many different apps. Look over the Counter Pattern with an Event example.
● The “Counter Pattern with Event” should look familiar! How would you
explain this pattern to another person? Make sure you step through each
line of the pattern.
● When might you want to use the “Counter Pattern with Event”?
for updating variables that you will use in making many different apps.
____________________________________________________________
Variable with String Concatenation
Variables can store many different types of information including numbers and Strings.
Anything placed inside of the quotation marks becomes a String. Guess what! There's a pattern
for working with Strings. When we want to combine Strings with other Strings, numbers, or
even with another variable we call that concatenation. Look over the Variable with String
Concatenation example.
CSP U4L2 Variables Investigate Activity Guide
● Type out how you would explain to a classmate how the “Variable with
String Concatenation Pattern” works. Make sure you step through each
line of the pattern.