Option III: Countdown

Starter Code

Often, we want to display text or numbers on the screen without using the say block. We have written a program that displays one number based upon a variable named digit. You can copy and remix the original program starter code. You should modify this program to work for five digits! (Initially, however, you may want to start by modifying it just to work with two digits.)

How Does the Original Code Work?

We have created a MyDigit sprite with ten different costumes, one for each digit, as shown below. Costume 1 corresponds to the digit 1, costume 2 corresponds to the digit 2 and so on. Costume 10 corresponds to the digit 0. Each costume has a name (for example, one, as shown below) and a number (for example, 1).

When we use the switch to costume block, we can specify either the name or the costume number. In the script below, we use the costume number (19) to set the costume unless the digit is 0. If the digit is 0, we cannot just tell it to switch to costume 0 (because there is no costume 0), so we have to use the name of the costume [zero].

Modulus

The mod block is essential to completing the program efficiently.

The modulus (mod) operator is used to return the remainder of a division operation. It might remind us how we answered division problems before we learned about decimals (e.g., 10 ÷ 3 = 3 remainder 1). Correspondingly, 10 mod 3 = 1. As you complete this assignment, consider the place value of each digit you need to change. If you count down from 25, you can isolate the 5 from 25 by performing a mod operation (25 mod 10 = 5). You can then isolate the 2 from 25 by performing the following operation:

[[25 - [25 mod 10]] mod 100] / 10

To see how this reduces to 2, note that

[[25 - [25 mod 10]] mod 100] / 10

= [[25 - 5] mod 100] / 10
= [20 mod 100] / 10
= [20] / 10 
= 2

For more explanation on the mod block, select the Help pane on the right side of the screen in Scratch.

Instructions

In this assignment, you will program a virtual countdown timer using Scratch. Your original program should:

  1. simulate a virtual countdown timer that can count from any five-digit number down to zero,
  2. remix the starter code provided,
  3. use loops for timed countdown functionality,
  4. use variables appropriately and as necessary,
  5. be personalized in at least three ways,
  6. be usable, efficient, and effective, and
  7. include documentation (describe what it does) in the Instructions pane. Be sure to describe how your program is original.

When you are satisfied with your work, submit a link to your program or the program itself. Your work will be reviewed by a peer, and in turn, you will review one of your peers’ projects. You should base your evaluation on the assignment rubric.