Can you give m ethe answers for the question below?

Jessika

Kunuk
Local time
Yesterday, 16:27
Joined
Feb 23, 2007
Messages
17
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
 
Jessika

This reads like homework/coursework. The idea being you are supposed to do it yourself.:eek:

If you at least post what how far you have got and what you are stuck on the contributors might feel inclined to help you a bit.

Chris
 
Problem Solving

Sorry forgot to tell you what IVE DONE SO FAR... I just wanted to know whether my answer and logic is correct.. Here below is what I did:
Question 1
CARD ONE with 43 as the sum of it PIN digits and the PIN 283746553 is keyed in.
Worker will be granted access as sum of PIN = 43

CARD TWO with 59 as the sum of its PIN digits and the PIN 987687891 is keyed in.
Worker will not be granted access as sum of PIN > 59

Question2
Initialize Count, Counta, Countb, Total, Totala and Totalb to zero
Read the sum of the PIN digits
While Count is lessthan eleven do
While Counta is lessthan eight do
Input a digit
Totala equals Totala plus digit
Counta equals Counta plus one
Endwhile
While Countb is greaterthan eight and lessthan eleven do
Input a digit
Totalb equals Totalb plus digit
Countb equals Countb plus one
Endwhile
Endwhile
Total = Counta & Countb //should be concatenate
If the Total equals the sum then allow access
Else sound alarm

Thanks for the advice,

Jessika
 

Users who are viewing this thread

Back
Top Bottom