Drinks Machine

Line: Loopy Line
Medium Difficulty Learning Outcome One Learning Outcome Three Learning Outcome Four Exercise
Type: Exercise
You should have completed:

Console Menu

This topic leads to:

Monthly Calendar

Summary

You are required to write an application that emulates a simple Drinks machine operating system. The user is offered 4 choices. These are tea with sugar and milk, tea with milk, or tea with sugar or quit.

The machine is required to keep a count of the number of each selection made and display it after each selection is made. Depending on their choice the machine will display a suitable message and will then display the number of that type of drink sold. The program is to keep working and offering the Menu until the user selects QUIT. Simple pseudocode for this might be :

     START
     DO
       SET UP  REQUIRED VARIABLES
       OFFER MENU  AND GET CHOICE
       PROCESS  CHOICE AND INCREMENT CHOICE_COUNTER
     WHILE 
       CHOICE IS NOT QUIT

Task

  1. Write a program to satisfy the above requirements
  2. Modify the program to include similar options for coffee
  3. Modify the program to keep track of the remaining stock of ingredients. Each of these ingredients has a maximum value of 10 when the machine is full
    1. servings of tea
    2. servings of sugar
    3. servings of milk
    4. servings of coffee
    5. cups
  4. Adjust the program so that when an ingredient has run out, the machine displays an error message and does not consume any of the other ingredients or 'dispense' a drink.