#C13989. Bank Account Manager Simulation

    ID: 43587 Type: Default 1000ms 256MiB

Bank Account Manager Simulation

Bank Account Manager Simulation

You are required to implement a bank account management system. The system should simulate the operations of a bank account with the following functionalities:

  • Create an account with a unique account ID, the account holder's name, and an initial balance of 0.
  • Deposit: Add a positive amount to the account balance. If the deposited amount \(\le 0\), the program should raise an error.
  • Withdraw: Subtract a positive amount from the account balance if sufficient funds exist. If the withdrawal amount \(\le 0\) or exceeds the current balance, the program should raise an error.
  • Balance: Output the current balance.
  • Account: Output the account details in the format: Account ID: <account_id>, Name: <name>, Balance: <balance>.

Note: All amounts are given as floating point numbers. For instance, a deposit of 100.0 is valid.

Implementation details: You need to design a class (or equivalent structure) called BankAccount that supports the above operations. Use appropriate error handling for invalid operations.

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  1. An integer representing the account ID.
  2. A string representing the account holder's name. This may contain spaces.
  3. An integer Q indicating the number of operations to perform.
  4. Each of the next Q lines contains an operation. The operation can be one of the following forms:
    • deposit X — Deposit the amount X (a float greater than 0) into the account.
    • withdraw X — Withdraw the amount X (a float greater than 0) from the account if sufficient balance exists.
    • balance — Print the current balance.
    • account — Print the account details in the format: Account ID: <account_id>, Name: <name>, Balance: <balance>.

outputFormat

For each operation that is a query (balance or account), output the result on a new line. For a balance query, print the current balance as a floating point number. For an account query, print the account details exactly in the following format:

Account ID: <account_id>, Name: <name>, Balance: <balance>

If an operation is deposit or withdraw, no output is required. Assume all input operations are valid.

## sample
1
John Doe
3
deposit 100.0
withdraw 50.0
balance
50.0

</p>