Homework Five

Write a program that allows users to enter and edit detailed pizza orders.

  1. For each order, the user may order up to 5 pizzas.
  2. For each pizza, the user can specify a size of small, medium, or large.
  3. Each pizza may have up to 5 toppings.
  4. Save all data for the order using an array of structs.
    Remember a struct is a type just like any other type.
    You can do things like pizza[3].size = 's';
    where pizza is a struct! Starting with a single pizza may be easiest.
  5. Print out the final order and verify it is correct.
  6. Optional: check the number of toppings/pizzas to see if you need an 's' when printing.
  7. Allow the user to select a single pizza by number and re-enter it.
  8. Be careful to show the user 1, 2, 3, ... as the pizza numbers even though the array will start from zero.
  9. Be sure to check all user input for simple errors.
  10. Extra credit: Can you specify which toppings are on the pizza? Try allowing sausage, onion, mushroom, anchovies, and walnuts. This makes the assignment twice as hard, by the way.
  11. Use separate functions for each part of your program!

Here's a sample run. The user's input is shown in BOLD.

How many pizzas would you like? 3

What size will pizza 1 be ? X
Please enter one of S, M, or L
What size will pizza 1 be ? S
How many toppings will be on pizza 1 ? 7
Sorry, you can't have more than 5 toppings.
How many toppings will be on pizza 1 ? 1
Pizza 1 is a small with 1 topping.

What size will pizza 2 be ? m
How many toppings will be on pizza 2? 3
Pizza 2 is a medium with 3 toppings.

What size will pizza 3 be ? L
How many toppings will be on pizza 3? 5
Pizza 3 is a large with 5 toppings.

Here is your order:

1. small pizza with 1 topping
2. medium pizza with 3 toppings
3. large pizza with 5 toppings

Is this correct? N

Which pizza would you like to change? 2

What size will pizza 2 be ? L
How many toppings will be on pizza 2? 1
Pizza 2 is a large with 1 topping.

Here is your order:

1. small pizza with 1 topping
2. large pizza with 1 topping
3. large pizza with 5 toppings

Is this correct? Y
Bon Appetit!