Workers entering a building used cards which have the sums of their 9 digit personal identification numbers (PIN) , stored on them. When a card holder passes a card through the card reader and keys in a 9 digit PIN, the follwing algorithm is used to check the validity of that PIN.
Initialise count and total to zero
Read the sum of the PIN digits
While count is lessthan nine do
Input a digit
Total equals total plus digit
Count equals count plus one
Endwhile
If the total equals the sum then allow access
Else sound alarm.
(i) Explain, with reasons, the output obtain for card 1 and card 2 when they are passed through the card reader with the following PINS keyed in:
CARD ONE with 43 as the sum of it PIN digits and the PIN 283746553 is keyed in.
CARD TWO with 59 as the sum of its PIN digits and the PIN 987687891 is keyed in.
(ii) Secret areas require eleven digit PIN. The sum of the first eight digits and the sum of the last three digits are stored on these cards. Modify and rewrite the algorithm to check a secret area PIN 8888 8888 888 which is keyed in after a card with 6424 stored on it has been passed through the card reader.
Thanks
Jessika
Initialise count and total to zero
Read the sum of the PIN digits
While count is lessthan nine do
Input a digit
Total equals total plus digit
Count equals count plus one
Endwhile
If the total equals the sum then allow access
Else sound alarm.
(i) Explain, with reasons, the output obtain for card 1 and card 2 when they are passed through the card reader with the following PINS keyed in:
CARD ONE with 43 as the sum of it PIN digits and the PIN 283746553 is keyed in.
CARD TWO with 59 as the sum of its PIN digits and the PIN 987687891 is keyed in.
(ii) Secret areas require eleven digit PIN. The sum of the first eight digits and the sum of the last three digits are stored on these cards. Modify and rewrite the algorithm to check a secret area PIN 8888 8888 888 which is keyed in after a card with 6424 stored on it has been passed through the card reader.
Thanks
Jessika