Overview
This topic has one learning objective (4.2.A): represent patterns and algorithms that involve everyday data sets, in written language or diagrams. Day 1 is unplugged: what a data set and a data value are (4.2.A.1), how the question decides the processing and when the data cannot answer it, and the three-part shape of every algorithm that analyzes a data set: set up, visit each value one at a time, report (4.2.A.2). Day 2 shows the data as a table or chart and uses a planning table to run a plan by hand before any code exists (4.2.A.3), then turns plans into Java that visits the values one at a time.
Students have written loops with accumulators, counters, and best-so-far variables (Topic 2.9), flags and character loops over a String (Topic 2.10), and read values one at a time from a Scanner built from a String (Topics 1.13 and 1.14). Topic 4.1 used the term data set while looking at the risks of collecting data. Stay inside the topic boundary: no arrays, no [], no ArrayList, and no text files. If a student asks how a program could keep all seven values, say that ways to store a whole data set come later in the unit and that today every value is read, used, and left behind.
Teacher note
The slides are the One at a Time deck (22 slides, with speaker notes); slide numbers below refer to it. Day 1 uses slides 1–13 and Day 2 uses slides 14–22. The One at a Time puzzle worksheet (10 questions, about 30 minutes) is split across both days: question 1 in class on Day 1 and question 2 as Day 1 homework; questions 4–6 in class on Day 2; questions 3 and 7–10 as Day 2 homework. Part C (questions 7–9) uses the character loop from Topic 2.10, so it fits after the Day 2 Java demonstrations.
Before Day 2, open these files from the topic’s examples/ folder in the IDE on the projector: StepGoalCount.java, HighestTemp.java, HighestTempZero.java, and StepTooMany.java (run-time error). Each is a full program that reads a Scanner over a String, so it runs without typing. For slides 19–20, paste the slide’s statements into the main of a scratch class.
Day 1 · Warm-up: A week of reading
Show slide 2: one student’s minutes read on five days (20, 35, 0, 45, 30). First ask the slide’s bottom question: “Is ‘20 minutes on Monday’ interesting by itself?” Not really; one number says little until it sits beside the others. Then pairs write three different questions this week could answer and, for each, what they would need to keep track of. Collect a few on the board, sorted roughly into “how much in all”, “how many”, and “which is biggest”. Leave them up; Part 2 names these kinds.
Day 1 · Direct instruction: What a data set is
- Goals (slide 3). Read the five goals; Day 1 covers goals 1 to 3.
- Data set and data value (4.2.A.1, slides 4–5). A data set is a collection of specific pieces of information about one subject; each piece is a data value. Walk the three features on slide 5 against the reading week: one subject (every value is minutes read in a day), specific (Thursday, exactly 45 minutes), and belonging together (one reader’s same week). Ask for everyday data sets: a team’s points per game, hourly temperatures, the songs a station played this morning. Point out that the last one is words, not numbers.
- A result is not a data value (slide 5, bottom). The week’s 130 minutes was calculated, not recorded on any day. Ask: “If I wrote 130 into the table as a sixth row and someone added the column, what would they get?” (260, the week counted twice.)
Misconception: A calculated result is one more data value
Students write a total or an average into the table as another row. It was never observed; it was computed from the data, and leaving it in the table makes the next calculation count the data twice. Keep two columns on the board for the rest of the lesson: “recorded” and “calculated”. Worksheet question 1 tests exactly this distinction.
Day 1 · Guided practice: The question decides the work
- Six kinds of question (4.2.A.2, slides 6–7). Data sets are analyzed to solve a problem or answer a question, and the question decides what has to be remembered. Walk slide 7’s table with the reading week, matching each kind to one of the warm-up questions on the board: running total, total then divide, counter, best so far, true/false flag (Topic 2.10), previous value.
- Three questions, one data set (slide 8). Reveal the library visitors (42, 57, 38, 61, 57) and have pairs answer each question before you reveal the answers: 3 days over 50 (a counter), 61 most visitors (best so far), average 255 ÷ 5 = 51 (a total, then divide). The fourth card, “How busy is the Oak Avenue branch?”, has no answer: every value describes Elm Street.
- Pause and try (slide 9). Pairs label each quiz-score question with counter, best so far, flag, or “can’t answer”. Answers: 1 counter; 2 best so far (the lowest); 3 flag (did anyone get 100?); 4 can’t answer, because the data records scores, not study time.
Misconception: Any question that sounds close can be answered
Students stretch a data set to a question it does not cover: from one bus route to the whole system, from March to December, from how many books to which books. The calculation still runs and produces a number, and the number is wrong for that question. Before planning any processing, ask: “Does every value I need actually appear in this data set?” Slide 8’s fourth card and slide 9’s question 4 are the class examples.
Day 1 · Direct instruction: Set up, visit each value, report
- One at a time (4.2.A.2, slides 10–11). When a data set is analyzed, its values are accessed and used one at a time, and each is processed for the result you want. Use the grocery cashier: items go past the scanner one at a time and the register total updates right then. Name the three steps on slide 11: set up (before any value), visit each value (add it, test it, or compare it), report (after the last value).
- Total minutes (slide 12). Read the plan in words, then fill the table one row at a time with the class calling out each
total: 0, 20, 55, 55, 100, 130. Introduce the term planning table: a row per value and a column per thing the algorithm remembers. Filling it in runs the plan by hand. Ask: “How many numbers did the plan hold at any moment?” (One.) - Setup goes before the first value (slide 13). Show only the wrong plan first and have students run it on the reading week before you reveal the result. The reset wipes the count at every value, so it reports 1 (only Friday’s 30 survives). The right plan reports 3: Tuesday, Thursday, and Friday.
Misconception: Putting the setup inside the for-each step
A plan that says “for each value: set count to 0, then if it matches add 1” reads almost right, but the reset repeats at every value and the result describes only the last one. Have students circle the setup line in every plan they write and check that it sits above “for each”. The same error comes back in Java on worksheet question 7.
Day 1 · Independent practice: Independent practice
Students do worksheet question 1 (pencil check): label each item data set, data value, result, or question. Circulate and look at the two results: June’s average high and the 41-goal season total are both calculated, so neither is a data value. Question 2 (the swimmer match-up) is homework; it covers all six kinds of question from slide 7, including one the data cannot answer.
Day 1 · Closure: Closure
Read one new question aloud: “Was there any day this week with no reading at all?” Students write what the plan must remember (a true/false flag), its setup (false), and what it reports for the reading week (true, because of Wednesday’s 0).
Day 2 · Warm-up: Read the chart
Students do worksheet question 4: Rosa’s books per month, shown as a chart and a table, with a goal of at least 5. The answer is 3 months (October, December, and January). Ask who missed December, then point out that “at least 5” includes 5. Ask which picture they used to answer, and why.
Day 2 · Direct instruction: Tables, charts, and planning tables
- Two pictures of one data set (4.2.A.3, slides 14–15). A data set can be shown as a table or a chart. The table lists the exact values and is best for tracing a plan step by step; the chart shows each value as a bar, so a pattern (which days passed the 30-minute line) jumps out at a glance. Either picture can be used to plan the algorithm.
- Planning the cheapest price (slide 16). Read the three-step plan, then fill the planning table with the class one row at a time. The best so far starts at the first value, 24 at store 1, because the first value is real data. Store 2’s 19 replaces it; 27 and 21 do not. The plan reports 19 at store 2.
- Ties (slide 16, follow-up question). Ask: “If store 4 had also charged 19, which store would the plan report?” Store 2, because 19 < 19 is false. With “less than or equal to”, it would report store 4, the last of the tied stores. Worksheet question 5 asks the same thing with snowfall.
Day 2 · Guided practice: The zero trap
- Starting the best so far at 0 (slide 17). Show the plan that starts
lowestat 0 and have students fill the planning table themselves on mini whiteboards before you reveal the slide. No positive price is less than 0, so nothing ever replaces it and the plan reports 0, a price that is not in the data set. The fix: start with the first value, then compare only the values after it. - Worksheet questions 5–6 in pairs. Question 5 is the snowfall planning table (most is 7 on day 3; with “greater than or equal to”, day 4). Question 6 is the same zero trap with winter lows below 0: claim 3 is the lie. Debrief question 6 by asking why 0 works for step counts but not for winter lows (step counts are never negative).
Misconception: Starting the best so far at 0
Students start a highest or lowest at 0 because a total and a count start there. It only works when 0 is beaten by real data. With prices, nothing is less than 0; with winter lows, nothing is greater. The planning table catches the mistake before any code is written: the column never changes. Start with the first value in the data set.
Day 2 · Direct instruction: From plan to Java
- Each column becomes a variable (slides 18–19). Setup goes before the loop, processing one value goes in the loop body, and the report goes after the loop. Slide 19’s flag visits the letters of
"PPPLPPP"one at a time and printsAny late days? true. Match each part of the code to the plan on the right of the slide. - Run
StepGoalCount.java(printsDays at goal: 4). TheScannerhands out the seven step counts one at a time; eachnextInt()reads the next value and the same value cannot be read twice. Then runHighestTemp.java(Warmest low: -1), the winter-lows plan in code: line 8 reads the first value as the start, so the loop handles nights 2 to 5.HighestTempZero.javastarts at 0 and printsWarmest low: 0, the slide 17 mistake in Java. - One line changed (slide 20). Students predict the output before you reveal it. It prints
Any late days? false: the assignment runs on every pass, so each letter overwrites the flag and only the last letter, a P, decides it. A flag is set to true when a value matches and never set back. - Count the data, not a guess. Run
StepTooMany.java: the loop runs whileday <= 8but the week has seven values, so the eighthnextInt()throws aNoSuchElementExceptionbefore anything prints. The loop must run once per value to read.
Misconception: Reading more (or fewer) values than the data set has
Students guess a loop’s bound instead of counting the data. Reading one value too many crashes with a NoSuchElementException (StepTooMany.java). Reading too few is worse, because nothing goes wrong on screen: the guide’s StepTotalSixDays.java silently leaves out Sunday and prints a wrong total. Have students count the values and state how many passes the loop makes before they run it. Worksheet question 9 is the same mistake from the other end: the loop starts at index 1 and skips the first letter.
Misconception: A flag that is set on every pass
Writing anyLate = …equals("L"); on every pass looks shorter than an if, but it lets a later non-matching value undo an earlier match. The flag then describes only the last value, the same problem as resetting a counter inside the loop. Slide 20 is the class example.
Day 2 · Closure: Closure and exit ticket
Show slide 21 and have students point to the one vocabulary word that names what they built on slides 12 and 16 (a planning table). Then slide 22: each student picks one question about the reading week and writes a three-step plan with the sentence starter. If time is short, this becomes the first line of homework. Then give the exit ticket (about five minutes).
Homework is worksheet questions 3 and 7–10, about 15 minutes: the table-and-chart face-off, the reset bug in Java (answer B, 1), the rainy-day code tiles, the one-token loop fix, and the vocabulary who-am-I. The worksheet’s Think First prompt asks whether a register can total many prices while remembering one number; slide 12 already answered it, so students should say yes.
Score the exit ticket question by question: question 1 checks whether the data set can answer a question (4.2.A.1, 4.2.A.2), question 2 the planning table (4.2.A.3), and question 3 choosing a correct one-at-a-time algorithm (4.2.A.2). Re-teach the weakest one at the start of the next topic.