#K86462. Banking System Simulation

    ID: 36870 Type: Default 1000ms 256MiB

Banking System Simulation

Banking System Simulation

You are required to implement a banking system simulation. The system supports creating accounts, depositing money, withdrawing money, transferring funds between accounts, and checking account balances. Each account is identified by a unique account number (a string). The commands are provided one per line and terminated by a command "END".

The supported commands are as follows:

  • CREATE <account_number>: Create a new account if it does not already exist. The initial balance is 0.
  • DEPOSIT <account_number> <amount>: Deposit the specified amount into the account. If the account does not exist, print ERROR.
  • WITHDRAW <account_number> <amount>: Withdraw the specified amount from the account if sufficient funds exist. Otherwise, print ERROR.
  • TRANSFER <from_account> <to_account> <amount>: Transfer funds from one account to another if both accounts exist and the source account has sufficient funds. Otherwise, print ERROR.
  • BALANCE <account_number>: Print the current balance of the account. If the account does not exist, print ERROR.
  • END: Terminate the simulation.

Remember that all outputs should appear in the order the commands are processed, each on its own line. Any error condition should output the exact string ERROR.

Note: Use LaTeX formatting for any formulas if needed. In this problem, if you wish, you can use the following representation for any formula (but it's not strictly required here):

$$\text{Balance} \geq 0$$

inputFormat

The input consists of multiple lines, each representing a command for the banking system. The commands include:

CREATE <account_number> DEPOSIT <account_number> WITHDRAW <account_number> TRANSFER <from_account> <to_account> BALANCE <account_number> END

The command "END" signals the termination of input.

outputFormat

For each command that requires an output (for example, the BALANCE command or error messages from invalid operations), print the output on a separate line. The outputs must appear in the order in which the commands are processed.## sample

CREATE 123
DEPOSIT 123 500
BALANCE 123
WITHDRAW 123 300
BALANCE 123
WITHDRAW 123 300
TRANSFER 123 456 100
CREATE 456
TRANSFER 123 456 100
BALANCE 456
BALANCE 123
END
500

200 ERROR ERROR 100 100

</p>