#K63092. Bank Account Management
Bank Account Management
Bank Account Management
You are required to implement a simple bank account management system. The system must support creating accounts, depositing funds, withdrawing funds, and checking the account balance. If a withdrawal exceeds the current balance, the system should output an error message in the form of Insufficient funds
. In this problem, you will simulate these operations by processing commands from standard input.
The system should support the following operations:
- CREATE: Create a new account with an account number, account holder's name, and an initial balance.
- DEPOSIT: Deposit a given amount into the specified account.
- WITHDRAW: Withdraw a given amount from the specified account. If amount > balance, print
Insufficient funds
immediately and do not change the balance. - BALANCE: Print the current balance of the specified account.
Note: All monetary values are floating-point numbers. When printing balances, output the float value directly (do not format unless necessary). The behavior of the system is governed by the following formula for a successful withdrawal:
\(\text{new_balance} = \text{old_balance} - \text{withdraw_amount}\)
inputFormat
The input is read from stdin and consists of multiple lines. The first line contains an integer \(N\) representing the number of operations. The following \(N\) lines each contain a command in one of the following formats:
CREATE account_number account_holder initial_balance
DEPOSIT account_number amount
WITHDRAW account_number amount
BALANCE account_number
Each command and its corresponding arguments are separated by spaces. You can assume that account numbers are unique and any operation on an account (other than CREATE) will refer to an account that exists.
outputFormat
For each command processed, output the following to stdout:
- For a
WITHDRAW
operation that fails due to insufficient funds, immediately printInsufficient funds
on a new line. - For a
BALANCE
operation, print the current balance of the account on a new line. - No output is required for
CREATE
orDEPOSIT
commands.
Ensure that each output is printed on its own line in the order in which the commands are processed.
## sample4
CREATE 1001 Alice 1000.0
DEPOSIT 1001 500.0
WITHDRAW 1001 200.0
BALANCE 1001
1300.0
</p>