Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10.5 (Savings-Account Class) Create the class SavingsAccount. Use the static var

ID: 3915897 • Letter: 1

Question

10.5 (Savings-Account Class) Create the class SavingsAccount. Use the static variable annual- InterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the sav- ingsBalance by annualInterestRate divided by 12-this interest should be added to savingsBal- Exercises 403 ance. Provide static method ModifyInterestRate to set the annualInterestRate to a new value. Write an app to test class SavingsAccount. Create two savingsAccount objects, saverl and saver2, with balances of $2000.00 and $3000.00, respectively. Set annual interes t Rate to 4%, then calculate the monthly interest and display the new balances for both savers. Then set the annualInterestRate to 5%, calculate the next month's interest and display the new balances for both savers.

Explanation / Answer

public class SavingsAccount
04
{
05
private double static annualInterestRate; //declare static variable
06
private double savingsBalance; //instance variable
07

08
public SavingsAccount(double bal); //constructor
09
{
10
savingsBalance= b;
11
}
12

13
public static double calculateMonthlyInterest() //calculates monthly interest
14
{
15
return(savingsBalance * annualInterestRate / 12);
16
}
17

18
static double modifyInterestRate() //declare static method
19
{
20
return annualInterestRate; //sets annualInterestRate to a new value
21
}
22

23
public void showBalance(

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote