Question: Create a class named AccountSaving s . This class has a static double variable which stores the annual interest rate for all account holders. The

Create a class named AccountSaving s . This class has a static double variable which stores the annual interest rate for all account holders. The name of variable is annualInterestRate . The class also has another double variable named saving s Balance which stores ba lance for current account.

a . Write a constructor to create a n account with specified balance. Add a validation whether the balance is greater than 0.0. If it is less than 0.0 then throw an exception.

b . Write a non - static calculateMonthlyInterest method to calculate the monthly interest by multiplying the saving s Balance by annualInterestRate divided by 12 the interest should be added to saving s Balance .

c . Write a static method named modifyInterestRate to set the annual i nterest rate. Add a validation whether the rate is g reater than equal to 0.0 and less than or equal 1.0. Otherwise, throw an exception.

d . Write a toString method which returns savingsBalance i n a string format.

After that, create AccountSaving s T est class. Create two object s from the class AccountSaving s with balances $2000.00 and $3000.00. Then, set the interest rate to 4%, then calculate the monthly interest r ate for each 12 months for each object and print the new balances with toString method for each object. UPLOAD AccountSavings.java AND AccountSavingsTest.java .

Example Output:

Create a class named AccountSaving s . This class has a static

Monthly balances for one year at .04 Balances Saver 1 Saver 2 $2000,00 $3000,00 $2006,67 $3010,00 Base Month 1: Month 2: $2013,36 $3020,03 Month 3: Month 4: Month 5: Month 6: Month 7: Month 8: Month 9 $2060,81 $3091,21 Month 10: $2067,68 $3101,51 Month 11: $2074,57 $3111,85 Month 12: $2081,48 $3122,22 $2020,07 $3030,10 $2026,80 $3040,20 $2033,56 $3050, 33 $2040, 33 $3060,50 $2047,14 $3070,70 2053,96 $3080,94

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!