← All Paper 2 problems·All lessons
Paper 2 scenario practice

Menu-driven item tracker

The scenario
A small business needs a simple inventory program with a menu. The program should: 1. Loop, repeatedly displaying a menu with three options: - 1: Add a new item (the program reads the item NAME and stores nothing more than the running COUNT of items added) - 2: View the current count of items added - 3: Quit the program 2. Read the user's choice as an INTEGER. 3. Use a CASE OF statement to perform the correct action. 4. Stop the loop only when the user picks option 3. 5. Handle invalid choices (anything other than 1, 2, 3) by displaying a message — the menu should then loop and ask again. Write a program in pseudocode (or a high-level language of your choice). Marks will be awarded for the menu loop with a quit condition, the CASE statement covering all branches, and clear program structure.
Lessons that prepare for this: Lesson 19 — Pseudocode and flowcharts · Lesson 23 — Programming concepts (WHILE, CASE OF) · Lesson 27 — Validation
Marking scheme — total 15 marks
Cambridge IGCSE 0478 Paper 2
  • 2
    Initialise variables and quit flag: DECLARE itemCount, choice, itemName, and a quit flag (or use the choice itself as the quit condition). itemCount ← 0 before the loop.
  • 3
    Outer loop with menu display: REPEAT or WHILE that displays the three-option menu each iteration and reads the user's choice. The loop must terminate when the user picks option 3 — typically WHILE choice <> 3 or REPEAT … UNTIL choice = 3.
  • 5
    CASE statement: CASE OF choice with one branch per valid option (1, 2, 3) plus an OTHERWISE branch for invalid input. ENDCASE properly placed. Each branch performs the correct action: 1 = read name and increment count; 2 = output count; 3 = output goodbye message and let the loop exit.
  • 3
    Add and view actions: Action 1 reads the name AND increments itemCount in the same branch. Action 2 outputs the current itemCount with a label.
  • 2
    Program structure and naming: REPEAT/UNTIL or WHILE/ENDWHILE properly paired; CASE OF/ENDCASE properly paired; clear identifiers; menu text readable.
Hints — reveal one at a time, only if stuck
Your pseudocode workspace
1 line