C3.1 Solve problems and create computational representations of mathematical situations by writing and executing efficient code, including code that involves events influenced by a defined count and/or subprogram and other control structures.

Activity 1: Budget


Ask the student to read the following order.

13 long sleeve shirts

15 sweaters

12 short sleeve shirts

30 jogging pants

10 rain coats

Short Sleeve Shirt Long Sleeve Shirt Sweater Jogging Pants Rain Coat
$10.99 $13.99 $15.99 $15.99 $23.99

Have the student create code that will determine the cost of the order. For example, the student could create buttons for each item that each contain code and alters a "SUM" variable.

Next, have students create subprograms that will be executed if certain conditions are met (for example, apply a 30% discount if the total exceeds $100, or offer a free item if the order exceeds 10 items).

Example of code with subprogram to apply a discount

Blocks of codeEvents block stating, “when green flag is clicked.”Variables blocks stating, “set sum to 0”. Variables blocks stating, “set total, open parenthesis with «H», «S», «T», closed parenthesis, to 0.”List block stating, “delete all of purchased items.”Control block stating, “repeat until answer equals N.”Inside 4 nested blocks. Sensing block stating, “ask what is the cost of the item, question mark, and wait.”List block stating, “add’’ motions block “answer” to purchased items”.Variables block stating, “change sum by’’ sensing block stating ‘’answer’’.Sensing block stating, “ask do you have another item to add, question mark, open parenthesis, y or n, closed parenthesis, and wait. Control block stating, “if sum greater then 100 then. Inside one nested block.My block stating, “30 percentage rebate”.Control block stating, “else”.Inside one nested block.Variables block stating, “set total open parenthesis, with «H», «S», «T», closed parenthesis, to sum multiplied by one decimal 13.
Blocks of codeMy block stating, “define 30 percentage rebate.”Variables block stating, “set amount saved to sum multiplied by zero decimal 3.”Variables block stating, “total, open parenthesis, rebate, closed parenthesis, to sum minus amount saved.”Variable block stating, “set total, open parenthesis, with «H», «S», «T», closed parenthesis, to total open parenthesis, rebate, closed parenthesis, multiplied one decimal 13.”

Activity 2: Measures of Central Tendency


Have students create subprograms that calculate the mean, median, mode, and range. These subprograms could then be executed at strategic locations in a main code that would analyze a data set.

This activity could be a continuation of Activity 1. For example, the student would create a subprogram that calculates the average unit cost of purchasing multiple items.