#C13169. Simulate a Bank Account

    ID: 42677 Type: Default 1000ms 256MiB

Simulate a Bank Account

Simulate a Bank Account

You are required to simulate a simple bank account.

The bank account supports three operations:

  • deposit X: Deposit an amount X into the account. The amount must satisfy \(X \ge 0\). If \(X < 0\), output "Error: Cannot deposit a negative amount." and ignore the deposit.
  • withdraw X: Withdraw an amount X from the account. The amount must satisfy \(X \ge 0\) and \(X \le balance\). If \(X balance\), output "Error: Insufficient funds for withdrawal." and do not change the balance.
  • balance: Print the current balance of the account.

The account starts with a balance of 0.

Process the operations in the order they appear.

inputFormat

The input begins with an integer N which represents the number of operations. The following N lines each contain an operation in one of the following forms:

  • deposit X (where X is an integer)
  • withdraw X (where X is an integer)
  • balance

Read from standard input.

outputFormat

For each operation that produces an output:

  • If a deposit or withdraw operation is invalid, output the corresponding error message immediately.
  • For the balance operation, output the current balance on a new line.

All outputs should be printed to standard output.

## sample
4
deposit 100
balance
withdraw 50
balance
100

50

</p>