Question
Complete the constructor of the SavingsAccount class that is a subclass of the BankAccount class. public class SavingsAccount extends BankAccount { private double interestRate; public
Complete the constructor of the SavingsAccount class that is a subclass of the BankAccount class.
public class SavingsAccount extends BankAccount { private double interestRate;
public SavingsAccount(double initialBalance, double rate) {
// your work here
}
/** Adds the earned interest to the account balance. */ public void addInterest() { double interest = getBalance() * interestRate / 100; deposit(interest); } public static double check(double initialBalance, double rate) { SavingsAccount account = new SavingsAccount(initialBalance, rate); account.addInterest(); return account.getBalance(); } }
Thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started