Write a java program that create a class savacnt, use a static variable anintrate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savbal indicating the amount the saver currently has ondep. Provide method calcmonthint to calculate the monthly interest by multiplying the savbal by anintrate divided by 12 this interest should be added to savbal. Provide a static method modiintrate that sets the anintrate to a new value.
Write a program to test class savacnt. Instantiate two savacnt objects, savel and save2, with balances 4000 and 6000, respectively. Set anintrate to 5%, then calculate the monthly interest and print the new balances for both savers. Then set the anintrate to 6%, calculate the next month's interest and print the new balances for both savers.
The answer to your question is provided in the image:
Comments
Leave a comment