Arithmetic Expressions and Assignments
Overview
In this lesson, students will write and interpret arithmetic expressions.
Learning Objectives
- 1.1.C.1 Write and interpret arithmetic expressions that use variables and constants.
- 1.1.C.2 Assign expressions to variables using assignment and compound assignment operators.
Skills
- S1.B Design algorithms for a program.
- S1.D Explain the impact design has on data storage.
- S2.A Write program code and implement algorithms.
- S2.C Analyze an algorithm and program code for correctness.
Student Outcomes
Students will be able to:
- identify when to use a constant
- write arithmetic expressions to solve problems
- interpret arithmetic expressions and determine the result
- use an assignment statement to update a variable's value
Duration: 1 class period
Resources
Warm-up / Motivate
Have students experiment with arithmetic operators by completing the practice: Practice: Experiment with Arithmetic Basics
Learn
Either as a group or on their own, have students review tutorial: Learn: Arithmetic Expressions and Assignments
Debrief: If students complete the tutorial independently, be sure to answer any questions students might have.
Highlighters can be used to highlight each step in the evaluation process.
Practice
Have students ask their favorite AI to generate some practice expressions to evaluate. Here's a sample prompt you might use: "To use with people just starting out in learning Java arithmetic expressions, generate a set of 10 expressions in Java that use the arithmetic operators."
Wrap-up / Extension
Create several sets of operation and number cards on index cards. Each set should include the following:
- each digit on it's own index card
0
- 9
.
- each operation on it's own index card
+
, -
, *
, /
, and %
.
- an open parenthesis
(
on one card and close parentheis )
on another.
Have students randomly create 10 expressions by pulling cards out of the set. It is adivisable to keep the number cards and operation cards separate. Students should write their expressions on a piece of paper.
Provide students with requirements for the length of the expressions in terms of the number of operations that are required. For example, maybe the first 2 have 1 operation, the next 2 have 2 operations, the next 3 have 3 operations, and the last 3 have parenthesis.
After students evaluate these expressions, they can use the Java Playground to check if their answers are correct.
Next Lesson
Lesson Plan: Introduction to Type Conversions with Casting