#C12737. Account Manager

    ID: 42197 Type: Default 1000ms 256MiB

Account Manager

Account Manager

You are required to implement an account management system to simulate basic banking operations. The system supports three types of accounts:

  • Basic Account: Has an account number, holder name, and balance.
  • Savings Account: Inherits from Basic Account and has an additional interest rate.
  • Current Account: Inherits from Basic Account and features an overdraft limit.

Each account supports the following operations:

  • DEPOSIT: Increases the balance. The deposit amount must be positive.
  • WITHDRAW: Decreases the balance. For a Basic or Savings account, the withdrawal amount must not exceed the current balance. For a Current account, the withdrawal is allowed as long as the balance does not drop below \( -\text{overdraft_limit} \).
  • DISPLAY: Displays the account details. For a Savings account, the interest rate is also shown. For a Current account, the overdraft limit is also shown.

The system receives a series of operations and processes them in order. If an operation cannot be performed (for example depositing a non-positive amount, or withdrawing an amount which violates constraints), print Error (without quotes). If an account is not found, print Account not found.

Note: All formulas, for example for limits, should be written in LaTeX format. For instance, the overdraft constraint is \( \text{balance} \ge -\text{overdraft\_limit} \).

inputFormat

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

  • CREATE Basic account_number holder_name balance
  • CREATE Savings account_number holder_name balance interest_rate
  • CREATE Current account_number holder_name balance overdraft_limit
  • DEPOSIT account_number amount
  • WITHDRAW account_number amount
  • DISPLAY account_number

Note: holder_name will not contain spaces (use underscores if necessary). All amounts and limits are floating point numbers.

outputFormat

For each operation DEPOSIT or WITHDRAW, output the new balance on a separate line if the operation is successful. For each DISPLAY operation, output the account details formatted as follows:

  • Basic Account: Account Number: [account_number], Holder Name: [holder_name], Balance: [balance]
  • Savings Account: Account Number: [account_number], Holder Name: [holder_name], Balance: [balance], Interest Rate: [interest_rate]
  • Current Account: Account Number: [account_number], Holder Name: [holder_name], Balance: [balance], Overdraft Limit: [overdraft_limit]

If an operation cannot be performed, print Error. If a DISPLAY operation is requested for an account that does not exist, print Account not found.

## sample
6
CREATE Basic 123 John_Doe 1000
DEPOSIT 123 500
WITHDRAW 123 400
DISPLAY 123
WITHDRAW 123 1500
DISPLAY 123
1500.0

1100.0 Account Number: 123, Holder Name: John_Doe, Balance: 1100.0 Error Account Number: 123, Holder Name: John_Doe, Balance: 1100.0

</p>