Now That’s How You Make Toast! Using Computer Algorithms.

Yesterday I discussed with my class the basics of Procedural Writing. My grade 8 students have been writing procedures for close to ten years now and I wanted to introduce a little Computer Science.

In my first year of Computer Science in the year 2000 I had to writer computer algorithms for trivial tasks like getting gas or making toast. We didn’t focus on any computer language in particular but rather the logical sequential instructions to complete a task.

Fast forward 14 years. The hour of code was last week. You can read about it here. Any students who participated on essentially built algorithms to move Angry Birds on the screen. Move forward, move forward, turn left, move forward. Success!

So yesterday we ran through the basics of Procedural Writing and making toast.

  1. Get bread from cupboard
  2. Remove toaster from drawer
  3. Put bread in toaster
  4. Turn on and sent temperature / timer
  5. When toast pops up add butter
  6. Eat and enjoy

As we discussed the steps, the students started to ask questions like “What if we are our of bread?” which lead to “Go buy some” and finally “What if I am out of money?”.

Perfect. The above example sounds like nested IF / ELSE statements to me! So I introduced it.

if(have bread) {make toast}

else { if(have money){go to store and buy bread}}

Next we discussed computer terms like GET, POST, INSERT, FETCH and switched them in for other words we had previously written. We even ended up using a WAIT.

WAIT UNTIL (toast pops up)

I went on to explain how I was 19 the first time I did this and it cost me $5000 for that first semester! These kids are 13 and internet resources are “free”. Pretty neat.



Breanna went on to explore as many possible cases she could think of for making toast and turned it into this flow chart.

Of course there was a debate about butter. “I want jelly” and “I want peanut butter” were shouted out across the room. So I rolled with it.

var topping = Prompt(What would you like on your toast?)

Before I finished my mini lesson, I wanted to bring in a real world example they are familiar with. If you have used any of the web apps I have developed over the years, you would have noticed very similar login screens. These students had all been on twiducate so I used it as an example.

if(user clicks teacher login){

show email input box

show password input box}

else {//student login

show class code input box

show password input box}

So there you have it. The thought process behind making toast is the same as coding a login form. I encourage all the language teachers out there to begin talking about the “what ifs” in procedural writing. Nested IF / ELSE statements become mini procedures within procedures. You could engage the entire class in a task.

if(out of bread) {group 1 procedure to go to store}

else {if (power is out) {group 2 procedure to turn on breaker}

           else { if(toaster is in drawer){group 3 procedure to get toaster ready}}

etc. etc.

I had a great time teaching this lesson. I talked about Boolean and ‘clauses’ in the computer world. I’m a nerd, what can I say.

Happy Holidays folks. Today is the last day of school here in Ontario.

(Visited 12,430 times, 2 visits today)

Leave a Reply

Email *