Pizza Robot – Flowchart

In this blog post we will design our own algorithms using both pseudo-code and flowcharts.

When given a problem to solve using a computer program you need to think about?

  • What are the main steps required to solve this program? (decomposition)
  • In which order will these steps be processed? (sequencing)
  • What information do I need to retrieve from the end user? (inputs)
  • What information do I need to display to the end user? (outputs)
  • What decisions will the computer need to make? (selection / if statements)
  • Is there any part of the process that can be repeated several times? (iteration / loops)

Then you can design your algorithm either in “plain English” (e.g. using pseudo-code) or using a visual representation (flowchart).

Scenario: Coffee Machine

Let’s look at the algorithm used in a tea/coffee machine.
The machine should:

  • Ask the user whether they want tea or coffee,
  • Add the tea or the coffee to the cup,
  • Ask the user whether they want milk,
  • If so, add milk to the cup,
  • Ask the user whether they want sugar,
  • If so, add sugar to the cup,
  • Pour the hot water into the cup.

Now let’s look at this algorithm using pseudo-code and using a flowchart:

Pseudo-codeFlowchart

flowchart-coffee-machine

Your Task: Pizza Robot


Adapt the above algorithm to use it in a pizza robot. Here is what the robot should do:

  • Welcome the user,
  • Ask what pizza base they need? (Thin, Thick)
  • Ask if they want tomato sauce or BBQ sauce?
  • Ask if they want cheese or not?
  • Cook the pizza for 20 minutes,
  • Serve the pizza

Extension:

  1. Ask if the user is vegetarian. If they are not, then ask if they want chicken on their pizza.
  2. The cooking time of the pizza varies: It should be 15 minutes for a thin base and 20 minutes for a thick base. Adapt your flowchart accordingly.

Create your pseudo-code and your flowchart using code2flow.com. Note you can reuse the code form the coffee machine to help you get started!
code2flow

Share Button
Tagged with: