# Overview

## Objectives — Students will be able to…

• Identify, declare, and assign variables.

## Assessments — Students will…

• Write a program that converts temperature from Fahrenheit to Celsius.

## Homework — Students will…

• Read the rest of BJP 2.2

• Complete self-check questions 5, 6, 9, 12-15 (4th edition: 6, 7, 10, 14-17)

# Materials & Prep

Since most of today’s lesson follows WS 2.2, you should have read through the worksheet. You may prefer to delete the notes from the worksheet (so it is only a sheet of exercises) if you are working on developing note-taking skills in your classroom. We recommend leaving these sections in for English Language Learner (ELL) classrooms, so your students can focus on syntax rules instead of translating what they are hearing to vocabulary they need to then write in their notebooks.

# Pacing Guide

 Section Total Time Bell-work and attendance 5min Introduction and worksheet exercises 25min Practice exercises 20min Turn in worksheets, wrap up 5min

# Procedure

Since much of this class involves learning syntax, there will be a lot of practicing during the class. Try to spice up the lesson by allowing students to work in pairs, or playing soft music in the background to put students in the right headspace to settle down for work.

Hook your class today by asking which of them are taking or have taken physics or chemistry. Ask students about working with Fahrenheit and Celsius temperatures—do they have to convert temperatures in class? Which measurement are they more familiar with? Which do they use more often? Show students the online calculator and ask if they ever use such online tools, and tell students that they’re going to learn how this program is built today.

## Introduction and Worksheet Exercises `[25 minutes]`

### Content - Debugging Tools

As you continue to program in IDE you will notice some of the debugging tools that are available to you. One of these tools is the syntax coloring whereby syntax errors will be highlighted or underlined a specific color. This draws the programmer’s attention to the error and allows for quicker fixes.

Even though these tools exist, it is still important for you to get good at identifying syntax and other errors. This will speed up the development process and will result in fewer errors in the final program.

1. Using WS 2.2, walk students through the proper way to declare a variable.

• Be sure to spot-check for understanding by having students give you the definitions of type, syntax, declaration, and variable (all bolded in the text).

• Encourage students to use their notes if needed.

2. Guide students through the syntax rules for variable declarations by working through the first few examples of Exercise 1 in pairs.

3. Give students a few minutes to complete Exercise 1 on their own; encourage students to tackle Exercise 2 as well, then check all answers together as a whole group.

4. Using the figure on Exercise 3 of WS 2.2, walk students through the proper syntax to assign a variable.

• Spot-check for understanding by asking students to define the italicized words.

• Ask students for a few sample answers, correct them if needed, then give students a few minutes to complete Exercise 3 in pairs.

5. As a whole group, walk students through Exercise 4 and 5. Complete 5a together as a group, then let students work on 5b in pairs.

At this point, your class may be raring to get started on the rest of the assignment without your help. If they are, great! Post the practice questions on the board so they can continue to that assignment once they have completed the worksheet. If your class wants you to walk them through string concatenation, go through the examples as above.

## Practice Exercises `[20 minutes]`

1. Have students complete the following practice self-check questions:

a. Self-Check 2.8: studentVariables

b. Self-Check 2.13: valuesOfABC

2. Have students complete Exercise 2.1: displacement.

3. Students should work on their own, but if the exercise is too challenging, you might opt to have students collaborate on answers. Be sure to remind students that each student should turn in their own set of work.

## Students turn in worksheets, wrap up `[5 minutes]`

At the end of class, collect WS 2.2 and practice problems submissions.

# Accommodation and Differentiation

If you have students who are speeding through this lesson, you should encourage them to:

• Complete Self-Check 2.18: timesOperator.

• Challenge them to build their own program that converts Fahrenheit to Celsius (this version won’t take user input—yet!)

• Have the student create a classroom poster diagramming the parts of variable declaration & assignment.

If your class is struggling with learning syntax, you can split the lesson into 2 lessons, and/or take off some of the homework questions. If splitting the lesson in two, we recommend stopping today’s lesson before string concatenation.

# Common Mistakes

Variables common mistakes: http://interactivepython.org/runestone/static/JavaReview/VariableBasics/commonMistakes.html

# Misconceptions

• Students will draw on their math knowledge when learning variables. This leads to confusion on the differences in a programming language.

• The equal sign `=` is assignment in Java, not equality. When reading out code, explicitly saying “assignment” will help reinforce the concept that `=` is not equality: `x = 1` is read as “x is assigned the value 1”.

• A variable is a container for value that can change, it does not denote a fixed value. From WS2.2, consider the following statements:

`int age = 17;age = age + 1;`

Students may view the second line of code as a math equation and miss the point that age is a variable and contains a value. The age = age + 1 changes the value of age. When learning Java there is the code which is static, the running of the code, and the state of the variable during runtime which is fundamentally different from an equation in math that can be substituted and manipulated to solve for some unknown.

• Students read `y = x + 2;` and think the equation is stored in y, not a value.

`x = 1;y = x + 2;x = 3;System.out.println (y); // what is displayed for y?`

For students with the misconception that the equation is stored, they will incorrectly compute 6 as what is displayed for y.

Java is not a spreadsheet that stores the equation. Explicitly teaching that x and y are independent variables in a programming language and hold values is an important distinction. This differs in math where `y = x + 2` is a relationship. Showing the state of the variables can be achieved using the whiteboard, the debugger by stepping through one line of code at a time, and examining variables, or using a visualization tool like http://cscircles.cemc.uwaterloo.ca/java_visualize/.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9158269,"math_prob":0.7541039,"size":6876,"snap":"2021-04-2021-17","text_gpt3_token_len":1507,"char_repetition_ratio":0.12485448,"word_repetition_ratio":0.010919018,"special_character_ratio":0.21175101,"punctuation_ratio":0.12378094,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9500147,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-04-23T13:19:45Z\",\"WARC-Record-ID\":\"<urn:uuid:432b34ec-8c73-40f2-95f7-614e06bbb90c>\",\"Content-Length\":\"386152\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:eea9a0bc-9555-44b3-9ec0-16b2523e720e>\",\"WARC-Concurrent-To\":\"<urn:uuid:2549a683-eddb-4395-9f61-b146570cef62>\",\"WARC-IP-Address\":\"104.18.1.145\",\"WARC-Target-URI\":\"https://tealsk12.gitbook.io/apcsa/unit-2-working-with-data-and-basic-control-flow-3-weeks/lesson-202\",\"WARC-Payload-Digest\":\"sha1:XTGX746TZR7PEIY2252TMTGLIP4K46ZB\",\"WARC-Block-Digest\":\"sha1:NUMGLGVAAU2REF5CKOVZP6Y3A4XTVBO3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-17/CC-MAIN-2021-17_segments_1618039594808.94_warc_CC-MAIN-20210423131042-20210423161042-00097.warc.gz\"}"}