Class for managing a bank account with transaction history

Java Medium classes

Task «Class for managing a bank account with transaction history»

Create a class `BankAccount` that stores a balance and a list of transactions. Implement the following methods: `deposit(double amount)` — deposit, `withdraw(double amount)` — withdrawal (cannot go negative), `getBalance()` — current balance, `getTransactionHistory()` — returns a list of strings in the format `"Deposit: 100.0"` or `"Withdraw: 50.0"`. In `main`, read from `stdin` the number of operations `n`, then `n` lines: each line contains `"D amount"` (deposit) or `"W amount"` (withdrawal). After processing all operations, output the final balance and the transaction history (each on a new line). Constraints: the amount is a positive `double`, `n ≤ 100`.

Input Format

The first line contains an integer n — the number of operations. Then n lines: each contains a character 'D' or 'W' and a space-separated floating-point number — the amount of the operation.

Output Format

First line: "Balance: X.XX" (balance with two decimal places). Then for each operation, a line of the form "Deposit: X.XX" or "Withdraw: X.XX" in the order of execution.

Examples

Example 1

INPUT
1 D 500.0
OUTPUT
Balance: 500.00 Deposit: 500.00

Example 2

INPUT
5
OUTPUT
Balance: 0.00
main.java