#C13446. Bank Account System
Bank Account System
Bank Account System
This problem requires you to implement a simple banking system that supports account creation, deposit, withdrawal, and balance inquiry. Account numbers are assigned incrementally starting from 1. Your program must read commands from standard input (stdin) and produce outputs to standard output (stdout). Error messages must match the specifications exactly.
Operations:
- CREATE <owner_name>: Creates a new account for the given owner with an initial balance of 0. Output the newly assigned account number.
- DEPOSIT <account_number> <amount>: Deposits the specified positive amount into the given account. If the amount is not positive, output
Deposit amount must be positive.
. If the account does not exist, outputAccount number does not exist.
. No output is produced for a successful deposit. - WITHDRAW <account_number> <amount>: Withdraws the specified positive amount from the given account. If the amount is not positive, output
Withdrawal amount must be positive.
. If the account does not exist, outputAccount number does not exist.
. If the account has insufficient funds, outputInsufficient funds.
. No output is produced for a successful withdrawal. - BALANCE <account_number>: Outputs the current balance of the account. If the account does not exist, output
Account number does not exist.
.
inputFormat
The first line contains an integer n, denoting the number of commands. Each of the following n lines contains one command in one of the following formats:
CREATE owner_name DEPOSIT account_number amount WITHDRAW account_number amount BALANCE account_number
Note: The owner_name is a single word, and account_number and amount are integers.
outputFormat
For each command that produces an output (CREATE and BALANCE) or results in an error, output the corresponding message on a separate line exactly as specified.## sample
4
CREATE John
DEPOSIT 1 100
WITHDRAW 1 50
BALANCE 1
1
50
</p>