ATM - Functions Functions Pseudocode Edited
ATM - Functions Functions Pseudocode Edited
FUNCTION processing_screen( )
BEGIN
OUTPUT " Processing"
FOR i ← 0 to i < 10
BEGIN
OUTPUT ".."
fflush(stdout) // Flush the output buffer
OUTPUT " " // ‘\b’ Move the cursor back by one character
END
END FOR
END
END FUNCTION
FUNCTION aborting_screen( )
BEGIN
OUTPUT " Exiting"
FOR i ← 0 to i < 10
BEGIN
OUTPUT ".."
fflush(stdout) // Flush the output buffer
OUTPUT " " // ‘\b’ Move the cursor back by one character
END
END FOR
END
END FUNCTION
FUNCTION PINcheck(PIN[6])
BEGIN
PINconfirm[6] ← { } // Array to store the confirmed PIN
p ← 0, not_match ← 0 // Counter variable and mismatch count
FOR i ← 0 to i < 6
BEGIN
IF PIN[i] != PINconfirm[i] THEN // Compare each character of the original and
confirmed PIN
not_match++ // Increment the mismatch count
END IF
END
END FOR
OUTPUT " " // ‘\n’
FUNCTION deposit(amnt)
BEGIN
depo_conf ← " ", rep ← " " // Variables for deposit confirmation and repetition
DO
BEGIN
IF INPUT depo_conf != 1 THEN // Check if the input is a valid integer
BEGIN
OUTPUT ">> Invalid input. Please enter 0 or 1."
getch()
WHILE getchar() != '\n' // Clear input buffer
END
ELSE
break
END IF
END
UNTIL 1
ELSE
BEGIN
OUTPUT "Invalid transaction. You cannot deposit a negative amount!"
getch()
END
END IF
OUTPUT "============================================"
DO
BEGIN
OUTPUT "Do you want to deposit again?"
OUTPUT "[1] Yes [0] No>"
ELSE
break
END IF
END
UNTIL 1
OUTPUT " " // ‘\n’
RETURN rep // Return the value indicating whether to repeat the deposit or not
END
END FUNCTION
FUNCTION withdraw(amnt)
BEGIN
wid_conf ← " ", rep ← " " // Variables for withdrawal confirmation and repetition
DO
BEGIN
IF INPUT wid_conf) != 1 THEN // Check if the input is a valid integer
BEGIN
OUTPUT ">> Invalid input. Please enter 0 or 1."
getch()
WHILE getchar() != '\n' // Clear input buffer
END
ELSE
break
END IF
END
UNTIL 1
ELSE
BEGIN
OUTPUT "Invalid transaction. Your withdrawn amount is bigger than your current
balance!"
getch()
END
END IF
OUTPUT "============================================"
DO
BEGIN
OUTPUT "Do you want to withdraw again?"
OUTPUT "[1] Yes [0] No >"
ELSE
break
END
END IF
END
UNTIL 1
RETURN rep // Return the value indicating whether to repeat the withdrawal or not
END
END FUNCTION
ELSE
RETURN 0 // Return 0 if the PINs match
END IF
END
END FUNCTION
FUNCTION inquiry( )
BEGIN
rep ← " " // Variable for repetition choice
OUTPUT ">>> Your current balance is P", curr_bal // Display the current balance
getch()
OUTPUT "============================================"
OUTPUT "Do you want to inquire your balance again?"
DO
BEGIN
OUTPUT "[1] Yes [0] No >"
IF INPUT rep != 1 THEN // Check if the input is a valid integer
BEGIN
OUTPUT ">> Invalid input. Please enter 0 or 1."
getch()
WHILE getchar() != '\n' // Clear input buffer
END
ELSE
break
END IF
END
UNTIL 1
RETURN rep // Return the value indicating whether to repeat the inquiry or not
END
END FUNCTION
FUNCTION exit_menu(conf)
BEGIN
IF conf == 1 THEN
BEGIN
OUTPUT
"#####################################################################
################"
processing_screen() // Simulate processing
OUTPUT ">>> Please get your card."
aborting_screen() //Simulate exiting
OUTPUT ">>> Thank you for using R2 Banking!"
END
END IF
END
END FUNCTION