curr_bal ← 5000
FUNCTION processing_screen( )
BEGIN
OUTPUT " Processing"
FOR i ← 0 to i < 10
BEGIN
OUTPUT ".."
fflush(stdout) // Flush the output buffer
// Add a delay to simulate loading
usleep(250000) // Sleep for 250 milliseconds (0.25 seconds)
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
// Add a delay to simulate loading
usleep(100000) // Sleep for 100 milliseconds (0.1 seconds)
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
OUTPUT "Confirm your PIN"
OUTPUT "Re-Enter PIN: "
DO
BEGIN
PINconfirm[p] ← getch() // Read a character from input
IF PINconfirm[p] != '\r' THEN // If the character is not the carriage return
OUTPUT "*" // Print an asterisk to mask the input
END IF
p++
END
UNTIL PINconfirm[p - 1] != '\r' && p <= 6 // Continue until carriage return or maximum
length is reached
PINconfirm[p - 1] ← '\0' // Terminate the confirmed PIN string
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’
RETURN not_match // Return the number of mismatches
END
END FUNCTION
FUNCTION deposit(amnt)
BEGIN
depo_conf ← " ", rep ← " " // Variables for deposit confirmation and repetition
OUTPUT ">>> You want to deposit P", amnt
OUTPUT "Do you want to proceed?"
OUTPUT "[1] OK 0] Cancel >"
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
IF amnt >= 0 THEN
BEGIN
IF depo_conf == 1 THEN
BEGIN
processing_screen()
OUTPUT "Deposit Successful!"
curr_bal += amnt // Add the deposited amount to the current balance
OUTPUT ">>> Your current balance is P", curr_bal
getch()
END
ELSE IF depo_conf == 0 THEN
BEGIN
OUTPUT ">> Deposit Unsuccessful!"
getch()
END
END IF
END
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>"
IF OUTPUT (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
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
OUTPUT ">>> You want to withdraw P", amnt
OUTPUT "Do you want to proceed?"
OUTPUT "[1] OK [0] Cancel >"
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
IF amnt < 0 THEN
BEGIN
OUTPUT "Invalid transaction. You cannot withdraw a negative amount!"
getch()
END
ELSE IF amnt <= curr_bal THEN
BEGIN
IF wid_conf == 1 THEN
BEGIN
processing_screen()
curr_bal -= amnt // Subtract the withdrawal amount from the current
balance
OUTPUT ">>> Your current balance is P", curr_bal
OUTPUT "Withdrawal Successful! Please get your money."
getch()
END
ELSE IF wid_conf == 0 THEN
BEGIN
OUTPUT ">> Withdrawal Unsuccessful!"
getch()
END
END IF
END
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 >"
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
END IF
END
UNTIL 1
OUTPUT " " // ‘\n’
RETURN rep // Return the value indicating whether to repeat the withdrawal or not
END
END FUNCTION
FUNCTION PINcompare(const char PIN[6], const char PIN2[6])
BEGIN
match ← 0 // Variable to count the number of matching digits
// Iterate over each digit in the PINs
FOR i ← 0 to i < 6
BEGIN
IF PIN[i] == PIN2[i] THEN
match++ // Increment the count if the digits match
END IF
END
END FOR
// Check if all digits match or not
IF match != 6 THEN
RETURN 1 // Return 1 if the PINs don't match
END
ELSE
RETURN 0 // Return 0 if the PINs match
END IF
END
END FUNCTION
FUNCTION inquiry( )
BEGIN
rep ← " " // Variable for repetition choice
processing_screen() // Simulate processing
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
OUTPUT " " // ‘\n’
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