#P3004. CAIE IGCSE CS May/June 2023 Paper 22 Problem 11
CAIE IGCSE CS May/June 2023 Paper 22 Problem 11
A two-dimensional (2D) array contains account holders’ names and passwords for a
banking program.
A 2D array 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:
and
and
The variable contains the number of accounts.
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 before any action can take place
- displays a menu showing the four actions available for the account holder to choose from:
- display balance
- withdraw money
- deposit money
- exit
- allows an action to be chosen and completed. Each action is completed by a procedure
with a parameter of the account ID.
Reapeat until a valid input is made, except the account number, id and password. If it is not valid quit the program
You should declare all variables you used
INPUT FORMAT
The first line contains , the account size
The second line to contains account name and account password for account number
From the line, there are queries, until user exits the program
The user enters their name and password
if name and password are valid then a choice is output until the user exits the program
There are chioce 1 to 4
- Choice 1: no input
- Chiice 2: contains withdraw amount until valid
- Choice 3: contains deposit amount until valid
- Chioce 4: no input
OUTPUT FORMAT
The following messages are used when necessary
Invalid Account NumberPlease Enter NamePlease Enter PasswordInvalid name or passwordYour balance is, balance (to one decimal place)Please enter amount to withdrawAmount greater than withdrawal limitAmount greater than cash availablePlease enter a positive amount to depositPlease enter your account numberAmount must be positiveMenu
1. display balance
2. withdraw money
3. deposit money
4. exit
please choose 1, 2, 3 or 4Invalid choice
SAMPLE
INPUT
6
Liam ueOkmUR9Os9g
Noah SDRfxjZwMW
Oliver yRNeC0t1Ei
Elijah P2qDyReF2N0
James VgAvenlj
William p8u3ZpLYssFD
410.0 70.0 240.0
600.0 120.0 90.0
530.0 150.0 280.0
-190.0 290.0 230.0
-120.0 210.0 80.0
-120.0 390.0 320.0
1
Liam
ueOkmUR9Os9g
3
100.0
1
2
19.0
1
4
OUTPUT
Please enter your account number
Please Enter Name
Please Enter Password
Menu
1. display balance
2. withdraw money
3. deposit money
4. exit
please choose 1, 2, 3 or 4
Please enter a positive amount to deposit
Menu
1. display balance
2. withdraw money
3. deposit money
4. exit
please choose 1, 2, 3 or 4
Your balance is 510.0
Menu
1. display balance
2. withdraw money
3. deposit money
4. exit
please choose 1, 2, 3 or 4
Please enter amount to withdraw
Menu
1. display balance
2. withdraw money
3. deposit money
4. exit
please choose 1, 2, 3 or 4
Your balance is 491.0
Menu
1. display balance
2. withdraw money
3. deposit money
4. exit
please choose 1, 2, 3 or 4