Академический Документы
Профессиональный Документы
Культура Документы
Procedure Main
Begin
If
(card is not inserted)
display “Insert Card”
Else,
If
(Card is inserted in wrong side)
display “Insert Card in proper side” and
Eject card
Else,
call Procedure CheckPin
END If
END If
END Main
Procedure CheckPin
Constants
MaxPins = 3
Variables
PinCounter is a Number
Begin
Read Data from Card
set PinCounter = 0
LOOP Until
PinCounter = MaxPins
input PIN from customer keypad
If
PIN matches Card PIN
Then
EXIT LOOP
END If
add 1 to PinCounter
END LOOP
If
PinCounter = MaxPins
Then
Block Card
Else,
call Procedure Services
END If
END CheckPin
1|Page
Procedure Services
Variables
Amount = 0
Account number is a number
Begin
Read Balance from card
Display Customer services
input selection from keypad
If
selection = withdrawal
Then
Call procedure withdrawal
Else If
selection = check balance
Then
display Balance
If
selection = Print Balance
Then
print Balance
Else If,
selection = back
Call procedure Services
END if
Else if
selection = Transfer credit
display Transfer Options
If
selection = Back
Then
Call Procedure Services
Else if,
display Amount
input selection from keypad
Amount = Amount + input
END If
If
Amount > Balance
display “You Don’t have sufficient Balance”
Else
display Account Number
input selection from keypad
If
Account Number is not in database
2|Page
display “Check Account Number”
Else
Transfer Amount to given Account Number
display “Transaction Successful”
Call Procedure Services
END If
END If
END Services
Procedure Withdrawal
Variables
Amount = 0
Begin
display withdraw options
If
selection = back
Then
Call Procedure services
Else
Read Balance from card
LOOP
display Amount
input from customer keypad
If
Amount < Balance
Then
Exit LOOP
Else
display “Insufficient Balance”
END If
END If
If
selection = Yes
Withdraw Amount
Print Amount
Print Balance
Print Date
3|Page
Print Time
Call Procedure Services
Else
Withdraw Amount
Call Procedure Services
END If
Else
Call Procedure Withdrawal
END Withdrawal
2.
3. A:
60 35 81 98 14 47
0 1 2 3 4 5
for i 0 to n -1 do
Count[i] 0
C:
0 0 0 0 0 0
0 1 2 3 4 5
When i = 0, A[i] = 60
j = 1, A[j] = 35
4|Page
j = 2, A[j] = 81
j = 3, A[j] = 98
j = 4, A[j] = 14
j = 5, A[j] = 47
When i = 1, A[i] = 35
j = 2, A[j] = 81
j = 3, A[j] = 98
5|Page
⸫Count[j] = Count[j] + 1
Count[3] = Count[3] +1
Count[3] = 1 + 1 = 2
j = 4, A[j] = 14
j = 5, A[j] = 47
When i = 2, A[i] = 81
j = 3, A[j] = 98
j = 4, A[j] = 14
j = 5, A[j] = 47
6|Page
After 3rd iteration,
C:
3 1 4 3 0 1
0 1 2 3 4 5
When i = 3, A[i] = 98
j = 4, A[j] = 14
A[i] < A[j] condition is not satisfied
⸫Count[i] = Count[i] + 1
Count[3] = Count[3] + 1
Count[3] = 3 + 1 = 4
7|Page