Jul 22 2008

Programming and PB&J

Teach computer programming using the simplicity of peanut butter and jelly sandwiches.

Teach computer programming using the simplicity of peanut butter and jelly sandwiches.

When writing programs, a computer programmer needs to be precise in content and in order. Inaccurate or vague steps (garbage in) will result in an incorrect result (garbage out). This introductory programming assignment gives students a lesson on thinking in terms of precise writing and sequential thinking. The best way to learn something new is to start with something students are already familiar with — making a peanut butter and jelly sandwich!

Lesson Description: In this assignment, students learn the importance of accurate, written communication and logical organization. The assignment requires the students to write a detailed, step-by-step program (paragraph) on how to make a peanut butter and jelly sandwich for homework. The next day, the students will input (read) their instructions to the computer (teacher). The teacher will “make” the programs, being sure to do exactly what the students say. For example, if a student says, “Take a piece of bread out of the bag,” the teacher should take only a small “piece” out instead of a slice. Or, rip the bag open without using the twist tie because the directions didn’t tell you exactly how to get to the bread.

Subject Area: This lesson can be used in a language arts or writing class to fulfill a technology lesson. It also makes a great lesson for a computer class to satisfy a writing-across-the-curriculum requirement as well as a prelude to a unit on programming. This lesson would be appropriate for middle levels, grades six through eight.

Curriculum Standards: The standards addressed in this lesson include: Pennsylvania Academic Standards for Science and Technology for Grade Seven

  • Explain and demonstrate basic computer operations and concepts
  • Explain basic computer communications systems

Pennsylvania Academic Standards for Reading, Writing, Speaking and Listening for Grade Eight

  • Write with a sharp, distinct focus
  • Write a multiparagraph informational piece
  • Write using well-developed content appropriate for the topic
  • Write with controlled organization
  • Revise after rethinking logic of organization

ISTE’s Educational Technology Standards for Students: Creativity and Innovation

  • Apply existing knowledge to generate new ideas, products or processes
  • Use models and simulations to explore complex systems and issues


  • Materials needed are peanut butter, jelly, bread, a butter knife and plenty of napkins. (You’d be surprised how many students forget to tell you to put the peanut butter or jelly on the bread, so you’ll need to spread it on your hands to prove the point.)
  • BASIC programming language

Grading Rubric: This activity can be graded as a single assignment to include participation through reading their program aloud, submission of the written directions, the final “look” of the peanut butter and jelly sandwich, or a combination of all three.

Students thoroughly enjoy this activity while at the same time learning the importance of precise writing and sequential thinking. With this lesson, they can visually “see” the errors, or bugs, in their programs.

Teaching Tips

  • Be aware of any peanut allergies before beginning this activity.
  • Make sure you have enough supplies; you may need more than one loaf of bread, depending on your class size.
  • Allow enough class time to enable everyone to participate.
  • As an extension, have students edit their own “computer programs” based on their observations, or use peer editing on this or another “how-to” activity.