Staging · for review, not public

Week 2 · Monday, Jan 11 · 2.1

Right side first

An assignment statement works out the value on the right side first, then stores it in the variable on the left, replacing the old value.

Minutes for each part of a 90-minute class.

Today we will

  • In Java, = means store, not equals. The right side is worked out first, then the value goes in the variable on the left.
  • A new value replaces the old one. The variable keeps no memory of what it held before.
  • A variable can use its own value: n = n + 3 reads n, adds 3, and stores the result back in n.
  • A variable must have a value before it is used, and the value must fit its type.
  • A trace table follows a sequence of assignments one line at a time. Swapping two values takes a third variable.
  • Programs can also get values while they run, as input from a keyboard, a file or a sensor.

Terms

assignment statementassignment operatorinitializeexpressiontrace tableinput

AP topics 1.4 · Learning objectives 1.4.A, 1.4.B · Skills 2.A, 3.A, 3.D, 4.A

0–10 min

Do Now

Warm up the moment you sit down. One code when you finish.

Open the Do Now
10–35 min

Demonstration

Chromebooks open. Follow along on the Follow along jobs in We Do / You Do while Mr. Muggivan works the examples.

10–75 min

We Do / You Do

Follow along, then Part A (with help), Part B (on your own) and stretch. One code for the whole block.

Open We Do / You Do
75–90 min

Exit Ticket

A few exam-style items to show what you learned today. One code.

Opens only in the last 15 minutes of class on this day.

Missed class? The Do Now and We Do / You Do stay open. Do them any time and submit your codes.