#C11994. Bank Account Manager
Bank Account Manager
Bank Account Manager
You are required to implement a bank account management system. The system supports the following commands:
CREATE account_number name
: Creates a new bank account with the specified account_number and name. The initial balance is 0.DEPOSIT account_number amount
: Deposits the specified amount into the account with account_number.WITHDRAW account_number amount
: Withdraws the specified amount from the account with account_number if there are sufficient funds.BALANCE account_number
: Prints the balance of the account with account_number.PRINT_ALL
: Prints the details of all accounts in the order they were created. For each account, printaccount_number name balance
on a separate line.
Process all commands read from standard input and produce outputs to standard output accordingly.
The solution should handle commands as described. Use the following representations:
Let \( b \) be the balance in an account. Initially, \( b = 0 \). After a deposit of \( d \), the balance is \( b+d \). A withdrawal of \( w \) is processed only if \( b \geq w \); otherwise, the balance remains unchanged.
inputFormat
The input consists of multiple lines. Each line contains a command in one of the following formats:
CREATE account_number name DEPOSIT account_number amount WITHDRAW account_number amount BALANCE account_number PRINT_ALL
Read input from standard input (stdin) until the end of file.
outputFormat
For each BALANCE
command, output the account's balance on a separate line. For the PRINT_ALL
command, output the details of each account (in the order they were created) on separate lines in the format:
account_number name balance
Output all results to standard output (stdout).
## sampleCREATE 12345 Joe
DEPOSIT 12345 1000
WITHDRAW 12345 500
BALANCE 12345
CREATE 54321 Jane
DEPOSIT 54321 2000
PRINT_ALL
500
12345 Joe 500
54321 Jane 2000
</p>