Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the constructor of the SavingsAccount class that is a subclass of the BankAccount class. Complete the following file: /** An account that earns interest

Complete the constructor of the SavingsAccount class that is a subclass of the BankAccount class.

Complete the following file:

/** An account that earns interest at a fixed rate. */ public class SavingsAccount extends BankAccount { private double interestRate;

/** Constructs a bank account with a given interest rate. @balance initialBalance the initial balance @param rate the interest rate */ 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); }

// This method checks your work. Do not modify it. public static double check(double initialBalance, double rate) { SavingsAccount account = new SavingsAccount(initialBalance, rate); account.addInterest(); return account.getBalance(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logics For Databases And Information Systems

Authors: Jan Chomicki ,Gunter Saake

1st Edition

1461375827, 978-1461375821

More Books

Students also viewed these Databases questions