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

START;

/Would you like Tea or Coffee?/;

if tea {
  Add Tea in cup;
} else {
  Add Coffee in cup;
}

/Would you like Milk?/;

if Milk {
  Add Milk in cup;
}

/Would you like Sugar?/;

if Sugar {
  Add Sugar in cup;
}

Pour hot water in cup;

END;
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

Did you like this challenge?

Click on a star to rate it!

Average rating 2.8 / 5. Vote count: 21

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: