An example of finding the volume of a rectangular prism with a length of 90, width of 100, and height of 50.


Students debug a program that is designed to calculate the volume of any size rectangular prism. This program uses variables and the ask and wait block to allow user input for the length, width, and height of the prism. Then it should calculate the volume of any rectangular prism, but there is a bug in the program. Students will debug the program.


Programming Skills with Scratch:

  • Create, name, use, and set the values of variables
  • Use the ask and wait block and the answer block
  • Debug a script
  • Nest multiplication blocks into a join block
  • Scratch blocks used: (ask and wait, answer, variables, set variable to, join, multiplication, say)


  1. Open and run the Scratch activity L x W x H Copy several times.A screenshot of the new variable dialog box.
  2. Be sure students know how to create, name, and set a variable.
    1. Click Data category.
    2. Click Make a Variable.
    3. Name the variable. Make sure to use a name that clearly explains what the variable represents.
    4. Click For all sprites.
    5. Click ok.
    6. The variable will appear on the stage. Right click the variable shown on the stage. There will be a drop down menu that allows you to select the type of readout the variable will have on the stage. Try all of them. This activity uses the large readout.
    7. Set the value of a variable by using the set variable to block from the Data category. Use the drop down menu to find the name of the variable you want to use.
  1. Make sure students know how to nest a join block and multiplication blocks into a say block. (Watch the first screencast tutorial.)
  2. Open the Volume L x W x H Scratch activity (student version). Explain that this activity does not work. It does not correctly give the volume of any rectangular prism. It has bugs in it. Students need to debug it.
  3. Decide if students should work with a partner or individually.
  4. Allow time for students to open, remix and debug the script so that it works correctly.


  • Allow time for student to make a generalized script that would solve a problem such as this:

    The volume of a rectangular prism is 24,000 cubic feet.
    The length of the prism is 30 feet.
    The width of the prism is 20 feet.
    What is the height of the prism?
    Example Volume Script

  • Let students explore Finding Missing Height of Prism Scratch activity.
  • Let students examine the Finding Area Scratch activity. There are problems with this project. It does not correctly find the area of a square, a rectangle, or a triangle. Debug the project and fix the scripts so that it gives the correct area for each figure.
  • When students have their script working properly, ask them to add script so that the program will not only tell the volume of any rectangular prism, but will also tell the surface area of the prism. Example Volume and Surface Area Script

Common Core:

5.MD.C.3, 5.NBT.B.5

CT/CS Standards and Skills:

CS-Solve problems by decomposing them into smaller parts, Debugging
CT-Work with variables, Use logical reasoning to explain how some simple algorithms work

Champaign Unit 4 School DistrictKenwood Elementary School: bright stars, bright futures
College of Education at IllinoisUChicago STEM EducationNSF
These lessons were written by Judy Rocke based on lessons developed at Kenwood Elementary School in the Champaign Unit 4 school district. Funding was provided by the National Science Foundation under award number 1542828. These lessons are intended to be used alongside the EM-4 curriculum.

Lessons prepared as web documents in Summer 2017. Contact us for updated lesson plan materials.