/** A savings account that has a balance, and interest*/public class SavingsAccount { private double balance; /** Constructs a bank account with a zero balance. */ public SavingsAccount() { this.balance = 0; } /** Constructs a bank account with a nonzero balance. @param initialBalance the initial balance */ public SavingsAccount(double initialBalance) { this.balance = initialBalance; } /** Deposits a given amount into the savings account @param amount the amount to deposit */ public void deposit(double amount) { this.balance = this.balance + amount; } /** Withdraws a given amount from the savings account @param amount the amount to withdraw */ public void withdraw(double amount) { this.balance = this.balance - amount; } /** Gets the current balance of the bank account @return the current balance */ public double getBalance() { return this.balance; } /** Applies the given interest rate to the account. @param interestRate the percent interest to give */ public void applyInterest(double interestRate) { double decimalInterest = interestRate / 100; if (this.balance > 0) { this.balance = this.balance + (decimalInterest * this.balance); } }}