Console Menu

Line: Input Line, Conditional Line, Loopy Line
Medium Difficulty Iteration Sequence Selection Learning Outcome One Learning Outcome Three Video
Type: Video
You should have completed:

Youth Calculator

Happiness Meter

Debugger

This topic leads to:

Temperature Conversion

Multiple Choice Question

Drinks Machine

Breakdown

Summary

As soon as a program becomes complex enough to do more than one thing for the user, it becomes important to for the user to be able to tell the program which one to do. This will involve everything you have learnt so far to create a functioning menu.

Selection is used to process the user's response to the menu, and iteration is used to repeat the menu to the user until they are ready to quit. Be careful to put the correct code inside the loop.

Task

  1. Watch the video

  2. Recreate the program yourself and test it

Questions

  1. How would you modify the program to give the user a character input choice e.g. 'a', 'b', 'c' etc?
  2. How would you modify the program to exit after three incorrect responses from the user?