Write a class to keep track of a balance in a bank account with a varying annual

Question:

Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the baland theanacnenual interest rate to some initial values (and you should also implement a no-arguments constructor that sets both the balance and the interest rate to zero).

The class should have methods to change or retrieve the current balance or interest rate. There should also be methods to make a deposit (add to the balance) or a withdrawal (subtract from the balance). 

Finally, there should be a method that adds interest to the balance at the current interest rate. This function should have a parameter indicating how many years’ worth of interest are to be added. (For example, 0.5 years indicates that the account should have six months’ interest added.)

Use the class as part of an interactive program that allows the user to determine how long an initial balance will take to grow to a given value. The program should allow the user to specify the initial balance, the interest rate, and whether there are additional yearly deposits.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: