Write a BankAccount
class that keeps track of the balance of a bank account. There should be two constructors–one that creates an empty bank account (with a balance of 0), and one that creates a bank account with some specified amount of money in it (indicated as a parameter in the constructor).
There are three methods for this class: deposit(amount)
, withdraw(amount)
, and getBalance()
.
After writing the BankAccount
class, write BankAccountTester.java
and, in its main()
method, constuct a couple of bank accounts and demonstrate how the methods work.
The BankAccountWithInterest
class has an additional method addInterest(rate)
which adds money earned as interest to the balance.