#C14327. Bank Account Manager

    ID: 43964 Type: Default 1000ms 256MiB

Bank Account Manager

Bank Account Manager

You are required to implement a simple bank account management system. The system supports creating accounts and performing operations such as depositing money, withdrawing money, and checking balances. Each account is uniquely identified by an account number.

The operations supported are:

  • CREATE initial_balance: Create a new account with the specified initial balance. The system should assign a unique account number to this account and output it.
  • DEPOSIT account_number amount: Deposit the given amount into the specified account. If the deposit amount is not positive, output an error message: Deposit amount must be positive.. On success, output OK.
  • WITHDRAW account_number amount: Withdraw the given amount from the specified account. If the withdrawal amount is not positive, output Withdrawal amount must be positive.. If the withdrawal amount exceeds the current balance, output Insufficient funds.. On success, output OK.
  • BALANCE account_number: Output the current balance of the specified account.

If any operation references a non-existing account, output Account number does not exist..

All operations are read from standard input and all outputs are written to standard output.

Note: The amounts may be floating-point numbers. All error messages and outputs must exactly match the specified text.

The implementation details are up to you. Make sure your solution can process all inputs from stdin and output to stdout accordingly.

inputFormat

The first line of input contains an integer N, representing the number of operations. Each of the next N lines contains one operation in one of the following formats:

  • CREATE initial_balance
  • DEPOSIT account_number amount
  • WITHDRAW account_number amount
  • BALANCE account_number

All tokens are separated by spaces.

outputFormat

For each operation, output the corresponding result on a new line:

  • For a CREATE command, output the newly assigned account number.
  • For a DEPOSIT or WITHDRAW command (if successful), output OK.
  • For a BALANCE command, output the current balance of the account.
  • If an error occurs (such as non-positive amounts, insufficient funds, or non-existent account), output the specific error message:
    • "Deposit amount must be positive."
    • "Withdrawal amount must be positive."
    • "Insufficient funds."
    • "Account number does not exist."
## sample
5
CREATE 100
DEPOSIT 1 50
BALANCE 1
WITHDRAW 1 30
BALANCE 1
1

OK 150 OK 120

</p>