Prepare a PL/pgSQL block that simulates an ATM transaction system.•If the withdrawal amount is less than or equal to 0, the block should display an "Invalid withdrawal amount" message.•If the withdrawal amount is greater than the account balance, the block should display an "Insufficient funds" message.•If the withdrawal amount is up to Rs. 20000, the block should perform a withdrawal and deduct the amount from the accountbalance.•If the withdrawal amount is up to Rs. 40000, the block should perform a withdrawal, deduct the amount, and apply a transactionfee 5%.•For withdrawal amounts greater than Rs. 40000, the block should perform a withdrawal, deduct the amount, and apply a highertransaction fee 18%.The block should also display the current account balance after each scenario
Question
Prepare a PL/pgSQL block that simulates an ATM transaction system.•If the withdrawal amount is less than or equal to 0, the block should display an "Invalid withdrawal amount" message.•If the withdrawal amount is greater than the account balance, the block should display an "Insufficient funds" message.•If the withdrawal amount is up to Rs. 20000, the block should perform a withdrawal and deduct the amount from the accountbalance.•If the withdrawal amount is up to Rs. 40000, the block should perform a withdrawal, deduct the amount, and apply a transactionfee 5%.•For withdrawal amounts greater than Rs. 40000, the block should perform a withdrawal, deduct the amount, and apply a highertransaction fee 18%.The block should also display the current account balance after each scenario
Solution
Sure, here is a PL/pgSQL block that simulates an ATM transaction system based on the requirements you provided:
DO $$
DECLARE
withdrawal_amount NUMERIC;
account_balance NUMERIC := 100000; -- Assume initial balance
transaction_fee NUMERIC;
BEGIN
withdrawal_amount := 50000; -- Set your withdrawal amount here
IF withdrawal_amount <= 0 THEN
RAISE NOTICE 'Invalid withdrawal amount';
ELSIF withdrawal_amount > account_balance THEN
RAISE NOTICE 'Insufficient funds';
ELSIF withdrawal_amount <= 20000 THEN
account_balance := account_balance - withdrawal_amount;
RAISE NOTICE 'Transaction successful. Current balance is Rs. %', account_balance;
ELSIF withdrawal_amount <= 40000 THEN
transaction_fee := withdrawal_amount * 0.05;
account_balance := account_balance - withdrawal_amount - transaction_fee;
RAISE NOTICE 'Transaction successful with 5%% fee. Current balance is Rs. %', account_balance;
ELSE
transaction_fee := withdrawal_amount * 0.18;
account_balance := account_balance - withdrawal_amount - transaction_fee;
RAISE NOTICE 'Transaction successful with 18%% fee. Current balance is Rs. %', account_balance;
END IF;
END $$;
This block first declares the variables withdrawal_amount, account_balance, and transaction_fee. It then checks the conditions you specified using IF-ELSIF statements. Depending on the condition that is met, it performs the appropriate actions and raises a notice with the current account balance.
Similar Questions
Write a PL/pgSQL block using an explicit cursor that will transfer the record of account no, customer name and balance from the“account” table to the “branch_surat” table if the branch name is surat in the “account” table. Furthermore, delete the record fromthe “account” table whichever record transfers to the “branch_surat” table.Use the following tables:account (ano, customer_name, balance, branch_name)branch_surat (ano, customer_name, balance)Create tables with Primary Key, foreign key constraints in given schemas
You are required to prepare the sequence diagram for withdrawing the money from the ATM for the following sequence of the events: The customer is able to make withdrawal of Money from the Bank ATM. The system employs the standard procedure for withdrawal of money by validating the card and account holder password. Assume that the main objects in this case are Customer and ATM.
Write an algorithm and draw a flowchart to show the steps of ATMcash withdrawal.
Draw the Sequence Diagram to Withdraw the Money from ATM
What if the ATM.html is the following:<form action="debit" method="POST"> <p><strong>Please select the amount that you want to withdraw from your account?</strong></p> <dl> <dd><input type="radio" name="Amount" value="1">1 </dd> <dd><input type="radio" name="Amount" value="10">10</dd> <dd><input type="radio" checked name="Amount" value="100">100</dd> <dd><input type="radio" name="Amount" value="1000">1000</dd> </dl> <p><input type="submit" value="Submit"> </p> </form> <form method="POST" action="credit"> <p><strong>Please select the amount that you want to deposit in your account?</strong></p> <dl> <dd><input type="radio" name="Amount" value="1">1 </dd> <dd><input type="radio" name="Amount" value="10">10</dd> <dd><input type="radio" checked name="Amount" value="100">100</dd> <dd><input type="radio" name="Amount" value="1000">1000</dd> </dl> <p><input type="submit" value="Submit" name="B1"></p> </form> <form method="GET" action="checkBalance"> <p><input type="submit" value="Check Balance" name="B1"></p> </form>
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.