An eighth grade computer science lesson on flowcharts and pseudocode

A vending machine algorithm is another example. Step 1: Accept money. Step 2: Check if amount is enough. Step 3: If enough.

Eighth graders write the “yes” path and forget the “no” path. That is the mistake I see most often when students first put an algorithm on paper. The steps work fine as long as the book is available or the student has the prerequisite. The moment the condition comes back false, the algorithm just stops, or worse, keeps going as if nothing happened.

So when the team asked what to put in front of the eighth grade computer science classes before the next coding unit, I pointed to Designing Algorithms with Flowcharts and Pseudocode. It runs about 45 minutes, and it is built around exactly that gap.

What the lesson asks students to do

The opener starts somewhere familiar: a person making a peanut butter sandwich in a kitchen, written out as a plain list of steps. That list gets a name, pseudocode, and from there the lesson moves to a library checkout. Scan the book. Check whether it is available. If it is, mark it checked out; if it isn’t, show an error. Short, but it has a real decision in it, and that decision is the whole point.

Algorithms are the foundation of all computer programs. A simple way to represent an algorithm is through a list of steps.

Then students take over. The guided practice has them design an algorithm for choosing an elective, with one catch: they have to check whether they have taken the required course first. It is a scenario every eighth grader understands, which means nobody gets stuck on the context and the thinking goes into the logic.

The lesson closes the loop with hospital triage software, where a system checks a patient’s symptoms, assigns a priority level, and makes sure the most urgent cases are seen first. Students tend to take sequence more seriously once they see what a misplaced step would cost.

The vocabulary is tight and worth posting on the board:

  • Algorithm: a precise, step-by-step set of instructions for a task or problem
  • Pseudocode: the steps written in plain language a person can read
  • Flowchart: a diagram using shapes and arrows to show the sequence
  • Conditional logic: a rule that triggers different actions depending on whether a condition is true or false

The lesson is aligned to CA.CS.6-8.AP.10 from the California computer science standards, in the Algorithms cluster of the Algorithms and Programming domain. It asks students to use flowcharts, pseudocode, or both to design and illustrate algorithms that solve complex problems. My opinion: treat that “and/or” as “and.” Students who can write the pseudocode but can’t draw the diamond with two arrows coming out of it usually haven’t fully seen the branch. The standard is identical in Long Beach Unified, Compton Unified, Lynwood Unified and Empire Union Elementary School District, and in every other California district teaching middle school computer science.

What to listen for while they work

Walk the room during the elective task and listen for the word “if” with no “otherwise” after it. That is your signal. Ask the student, “What happens if you haven’t taken the required course?” Most will fix it on the spot.

Listen for order, too. Some students will write “enroll in elective” and then “check prerequisite.” Read it back to them literally and let them hear the problem.

Vague steps are the third thing. “Pick an elective” is a wish, not an instruction. A computer needs to know what it is checking and what it does with the answer.

One honest caveat. The worked examples are short, one decision each. If you want students genuinely at the “complex problems” end of this standard, push your faster finishers to add a second condition to their elective algorithm and redraw the flowchart. The lesson gives you the structure; the stretch is on us.

Fitting it into the week

I’d run it as a whole-class lesson early in the week, before anyone opens a coding environment, so the planning habit is in place when the syntax arrives. It also works well for a student who missed the week: the sandwich, library and elective scenarios need no prior unit context to make sense.

Imagine a light sensor that turns on a lamp when it gets dark. The steps are: 1. Check light level. 2. If light is low, turn.

And if you have a sub coming, this is a strong pick. A substitute doesn’t need computer science background to run an eighth grade flowchart and pseudocode lesson, and you’ll come back to a stack of elective algorithms you can sort in five minutes by one question: did they write the “no” branch?