CAMBRIDGE IGCSE COMPUTER SCIENCE
Summer 2023 · Paper 22 · Question 12 · 15 marks
← 0478 CS Hub Paper 22 · Summer 2023 0478 / Paper 2 Question 12 15 MARKS
15-mark question lab · start here

Check the login, then serve the four-action bank menu.

Build the solution in a sensible order: decode the three requirements, plan the two global arrays and the shared account ID, gate every action behind the login check, display the menu and dispatch each choice, and complete every action in a procedure that receives the account ID as its parameter. Learn the reasoning before revealing the complete program.

2D arraysLogin validationMenu loopProcedures with parametersError messages15 marks

Learning targets

By the end, you should be able to explain the algorithm before writing it.

Lesson overview

01 · Understand

Identify the two global arrays, the row index both share as the account ID, and the three requirements hidden in the bullet list.

02 · Construct

Build the program in order: a login check that confirms the account ID, name and password, a menu loop driven by CASE OF, and one PROCEDURE with an account ID parameter for each action.

03 · Complete

Guard every withdrawal with the overdraft limit and the withdrawal limit, display a suitable error message for every refusal, and exit cleanly on menu choice 4.

!

How Cambridge awards the marks: the mark scheme gives AO2 a maximum of 9 marks and AO3 a maximum of 6 marks. It lists requirements R1–R5, but does not assign a separate fixed mark total to each R requirement. The stage-to-mark links in this guide show alignment, not invented stage marks.

Source question

Read the whole question first

Do not begin coding after the first paragraph. The shared row index, the three columns of AccDetails[] and the phrase “with a parameter of the account ID” all fix the shape of your solution.

Question 12 · 15 marks
Cambridge IGCSE Computer Science · 0478/22 · Question 12

A two-dimensional (2D) array Account[] contains account holders’ names and passwords for a banking program.

A 2D array AccDetails[] has three columns containing the following details:

  • column one stores the balance – the amount of money in the account, for example 250.00
  • column two stores the overdraft limit – the maximum total amount an account holder can borrow from the bank after the account balance reaches 0.00, for example 100.00
  • column three stores the withdrawal limit – the amount of money that can be withdrawn at one time, for example 200.00

The amount of money in a bank account can be negative (overdrawn) but not by more than the overdraft limit.

For example, an account with an overdraft limit of 100.00 must have a balance that is greater than or equal to –100.00

Suitable error messages must be displayed if a withdrawal cannot take place, for example if the overdraft limit or the size of withdrawal is exceeded.

The bank account ID gives the index of each account holder’s data held in the two arrays.

For example, account ID 20’s details would be held in:

Account[20,1] and Account[20,2]
AccDetails[20,1] AccDetails[20,2] and AccDetails[20,3]

The variable Size contains the number of accounts.

The arrays and variable Size have already been set up and the data stored.

Write a program that meets the following requirements:

  • checks the account ID exists and the name and password entered by the account holder match the name and password stored in Account[] before any action can take place
  • displays a menu showing the four actions available for the account holder to choose from:
    • 1. display balance
    • 2. withdraw money
    • 3. deposit money
    • 4. exit
  • allows an action to be chosen and completed. Each action is completed by a procedure with a parameter of the account ID.

You must use pseudocode or program code and add comments to explain how your code works.

All inputs and outputs must contain suitable messages.

You only need to declare any local arrays and local variables that you use.

You do not need to declare and initialise the data in the global arrays Account[] and AccDetails[] and the variable Size

Before you move on

These are the five required techniques identified by the Cambridge mark scheme.

Mark-scheme map
R1

Check the account ID exists and the entered name and password match Account[] — iteration, validation, selection, input and output.

R1

Gate every action behind the login check, reading Account[ID,1] and Account[ID,2] through the shared row index.

R2

Display the four-action menu and read the account holder’s selection, dispatching it with CASE OF — output, input and selection.

R2

Repeat the menu until choice 4 is entered, refusing invalid choices with a suitable message.

R3

Perform each selected action with the arrays inside a PROCEDURE that takes the account ID as its parameter.

Use the tabs along the top to work through the seven stages. The complete solution is kept in its own tab, and the interactive visualisation is the final tab.