5.4 Math Game

Students will make a multiplication game. This is a useful game for all middle-school, as it helps with math facts!
This game uses variables of type number; ask/answer; and a multiplication operator. Students should plan their steps, starting at high level steps before delving into details.

OBJECTIVES:




OBJECTIVES: By the end of this lesson, students will:

    • design, abstracting details to lower levels.

    • use variables to store numbers and score.

    • apply random and multiply commands

    • recall the importance of naming descriptively

TEACHER RESOURCES:

Standards

    • CSTA 2-AP-10: Use flowcharts and/or pseudocode to address complex problems as algorithms.

    • CSTA 2-AP-11: Create clearly named variables that represent different data types and perform operations on their values.

CSTA

DO NOW:

Students watch the video Draymond Green (0:56) , then discuss:

    • What is Draymond Green's advice to high-school students?

    • Does Draymond Green believe that Computer science is a necessary tool for life in the 21st Century?

Teacher Guidance

  • Go after it. Hard work beats talent when talent fails to work hard.

  • Yes, Basketball has taken Draymond so many places and computer science can take you so many places too. Draymond says that CS "is necessary tool in life to be successful".

Mini-Lesson (5-10 minutes)

Mini-Lesson (5-10 minutes)

1. Demo Game. Who would be the audience for this game? What steps would you need make this game?


Show students that they can hide complexity at a lower level. This is known as Top-Down Design.


Hiding complexity to a lower level is a programming tactic known as Abstraction.

Abstraction makes code more readable and more generic so that it can be easily adapted to a wider variety of scenarios.

2. Show students the math operators that reside under operators including the multiplication operator they will use today.

3. Today students will use variables to store numbers. Variables can store an boolean -(TRUE/FALSE) , a word ( Text) or a number.

Project (20-30 minutes)

Let students begin, using student handout found on the student page.

Abstraction is a key computer science concept as it allows simplification of complex systems. In unit 6 students will be introduced to procedures, a form of abstraction in code.

Close-Out (5 minutes)

Close-Out (5 minutes)

Today you used abstraction. You created a high level plan that hid the complexity at a lower level.
Discuss the following questions:

    1. Why is it a good idea to hide complexity at lower levels?

    2. Multiplication is a math command, shown under operators. What other math commands can you find under operators?

    3. Look at your coding blocks. How many variables did you use. Explain to a partner why you needed each of these variables in your code.

Potential Responses

  • Abstraction hides details at a lower level to simplify complex systems.
    It improves efficient and makes code easier to read.
    It also allows your code to work with a bigger range of scenarios.
    E.g. The Madlibs
    project generated lots of sentence output, form one sentence frame and a variety of two word inputs.

  • Math operators: Addition, subtraction, divide, mod, round.

        • Mod returns the remainder - useful for telling if a number is odd or even.

        • Round: rounds to the nearest whole number.

        • Note: Square root can be changed to 14 other math functions including sin and cosine.

  • Students use four variables:

  • Number 1, Number 2: to hold random numbers, used in formulating game question and calculating.

  • CorrectAnswer: to store the correct math answer

  • Score: to store the players' score.