Question: Program in Java using NetBeans Create class SavingsAccount. Use a static variable annuallnterestRate to store the annual interest rate for all account holders. Each object
Program in Java using NetBeans
Create class SavingsAccount. Use a static variable annuallnterestRate 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 savingsBalance by annuallnterestRate divided by 12- this interest should be added to savingsBalance. Provide a static method setInterestRate that sets the annuallnterestRate to a new value. There should also be a method setSavings Balance to set the initial savings balance for a new saver or you can do it through a constructor. Write a program to test class SavingsAccount. Instantiate two SavingsAccount objects, saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set annuallnterestRate to 4% then calculate the monthly interest for 12 months and print the new balances for both savers. Next, set the annuallnterestRate to 5%, calculate the next month's interest and print the new balances for both savers. The output should have 12 months at 4% interest and 1 month (month 13) at 5% interest. Make sure your dollar amounts are displayed to two decimal places. Put the code to test the class in the main method of the Savings Account Class. The output of your program should look like the following: Untitled - Notepad File Edit Format View Help Savings Account Balances Month Saver1 Saver 2 2006.67 3010.00 2013. 36 3020.03 2020.07 3030.10 2026.80 3040.20 2033.56 3050.33 2040.33 3060.50 2047.14 3070.70 2053.96 3080.94 2060.81 3091.21 2067.68 3101.51 11 2074.57 3111.85 12 2081.48 3122.22 13 2090.16 3135.231 HNMONOHHH
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
