#C14871. Bank Account Operations

    ID: 44568 Type: Default 1000ms 256MiB

Bank Account Operations

Bank Account Operations

You are required to implement a BankAccount class to simulate basic banking operations. The account should support deposit, withdraw operations (with an insufficient funds check), and retrieving the current balance. When a withdraw operation is attempted and the available balance is insufficient, the program must immediately print the message Insufficient funds and skip the withdrawal.

After processing all operations, output the final balance of the account. The operations are provided via standard input, and the output (including any "Insufficient funds" messages) must be printed to standard output.

Functionality:

  • deposit(amount): Adds the specified amount to the balance.
  • withdraw(amount): Deducts the specified amount from the balance if sufficient funds exist; otherwise, prints Insufficient funds.
  • getBalance(): Returns the current balance.

inputFormat

The input is given via standard input and has the following structure:

  1. A string representing the account number.
  2. A string representing the account holder's name.
  3. A floating-point number representing the initial balance.
  4. An integer n that denotes the number of operations to process.
  5. n subsequent lines, each representing an operation. Each operation is provided in one of the following forms:
  • deposit X: Deposit the amount X.
  • withdraw X: Withdraw the amount X (if sufficient funds exist).

outputFormat

The output should be printed to standard output and include:

  1. Any messages Insufficient funds that occur during processing (each printed on a new line as they occur).
  2. The final balance of the account printed on the last line.
## sample
1234
John
1000
3
deposit 500
withdraw 300
withdraw 1500
Insufficient funds

1200

</p>