Вы находитесь на странице: 1из 7

1.

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

Balance = Balance – Amount

display Confirmation options


If
selection = Yes
display “Do you need a receipt for your transaction?”

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.

Starting Side Time (mins) Ending Side


A,B,C,D - -
C,D 2 A,B
A,C,D 3 B
A 13 B,C,D
A,B 15 C,D
- 17 A,B,C,D

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

A[i] < A[j] condition is not satisfied,


⸫ Count[i] = Count[i] + 1
Count[0] = Count[0] +1
Count[0] = 0 + 1 = 1

4|Page
j = 2, A[j] = 81

A[i] < A[j] condition is satisfied


⸫Count[j] = Count[j] + 1
Count[2] = Count[2] + 1
Count[2] = 0 + 1 = 1

j = 3, A[j] = 98

A[i] < A[j] condition is satisfied


⸫Count[j] = Count[j] + 1
Count[3] = Count[3] + 1
Count[3] = 0 + 1 = 1

j = 4, A[j] = 14

A[i] < A[j] condition is not satisfied


⸫Count[i] = Count[i] + 1
Count[0] = Count[0] + 1
Count[0] = 1 + 1 = 2

j = 5, A[j] = 47

A[i] < A[j] condition is not satisfied


⸫Count[i] = Count[i] + 1
Count[0] = Count[0] + 1
Count[0] = 2 + 1 = 3

After 1st iteration,


C:
3 0 1 1 0 0
0 1 2 3 4 5

When i = 1, A[i] = 35

j = 2, A[j] = 81

A[i] < A[j] condition is satisfied


⸫Count[j] = Count[j] + 1
Count[2] = Count[2] + 1
Count[2] = 1 + 1 = 2

j = 3, A[j] = 98

A[i] < A[j] condition is satisfied

5|Page
⸫Count[j] = Count[j] + 1
Count[3] = Count[3] +1
Count[3] = 1 + 1 = 2

j = 4, A[j] = 14

A[i] < A[j] condition is not satisfied


⸫Count[i] = Count[i] + 1
Count[1] = Count[1] + 1
Count[1] = 0 + 1 =1

j = 5, A[j] = 47

A[i] < A[j] condition is satisfied


⸫Count[j] = Count[j] + 1
Count[5] = Count[5] + 1
Count[5] = 0 + 1 = 1

After 2nd iteration,


C:
3 1 2 2 0 1
0 1 2 3 4 5

When i = 2, A[i] = 81

j = 3, A[j] = 98

A[i] < A[j] condition is satisfied


⸫Count[j] = Count[j] + 1
Count[3] = Count[3] + 1
Count[3] = 2 + 1 = 3

j = 4, A[j] = 14

A[i] < A[j] condition is not satisfied


⸫Count[i] = Count[i] + 1
Count[2] = Count[2] + 1
Count[2] = 2 + 1 = 3

j = 5, A[j] = 47

A[i] < A[j] condition is not satisfied


⸫Conut[i] = Count[i] + 1
Count[2] = Count[2] + 1
Count[2] = 3 + 1 = 4

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