#K77692. Bank System Simulation

    ID: 34921 Type: Default 1000ms 256MiB

Bank System Simulation

Bank System Simulation

You are tasked with simulating a simple bank system. The system supports the following operations on bank accounts: creating an account, depositing funds, withdrawing funds, and checking the balance. Each account is identified by a unique 5-digit number and the system supports at most 10 accounts. The commands are provided as input via standard input (stdin) and the responses should be printed to standard output (stdout).

The operations are defined as follows:

  • CREATE <account_number>: Create a new account. The response will be 'Account {account_number} created' if successful, or 'Account {account_number} already exists' if the account already exists, or 'Account limit reached' if the account limit has been reached.
  • DEPOSIT <account_number> <amount>: Deposit a specified amount into the account. Prints 'Deposited {amount} to {account_number}' if successful, or 'Invalid account' if the account does not exist.
  • WITHDRAW <account_number> <amount>: Withdraw a specified amount from the account. If the funds are insufficient, print 'Insufficient funds'; if the account does not exist, print 'Invalid account'; otherwise prints 'Withdrew {amount} from {account_number}'.
  • BALANCE <account_number>: Print the current balance in the format 'Account {account_number} balance {amount}', or 'Invalid account' if the account does not exist.
  • QUIT: Terminate the input processing.
For invalid commands or wrong number of arguments, print 'Invalid Operation'.

inputFormat

The input consists of multiple lines. Each line contains a command. The commands are one of the following:

  • CREATE <account_number>
  • DEPOSIT <account_number> <amount>
  • WITHDRAW <account_number> <amount>
  • BALANCE <account_number>
  • QUIT
The input terminates when the command QUIT is encountered.

outputFormat

For each command (except QUIT), output the corresponding response on a separate line to stdout. The responses should exactly match the format described in the problem statement.## sample

CREATE 12345
CREATE 12345
QUIT
Account 12345 created

Account 12345 already exists

</p>