Write the classes Transaction and Account, and a public class AccountHistory.
- A
Transactionrecords its number, its type ('D'deposit or'W'withdrawal), the amount, the balance after the operation and a description; itstoString()formats one line of the statement. - An
Accounthas an owner, an id, a balance and a privateArrayList<Transaction>.deposit(amount, description)andwithdraw(amount, description)update the balance and add a transaction;withdrawreturnsfalse, and records nothing, when the balance is too low. Also writegetTransactionCount(),getTransaction(int)andtotal(char type).
main reads owner id openingBalance, then operations D amount description or W amount description until the end of the input, and prints the statement. For the input
George 1122 1000
D 30 salary
D 40 gift
W 5 coffee
W 2000 car
W 4 bus
D 50 refund
the program prints
Account 1122 of George opens with 1000.00
Refused: 2000.00 for car (balance 1065.00)
# T Amount Balance Description
1 D 30.00 1030.00 salary
2 D 40.00 1070.00 gift
3 W 5.00 1065.00 coffee
4 W 4.00 1061.00 bus
5 D 50.00 1111.00 refund
Deposits 120.00, withdrawals 9.00, final balance 1111.00