29.0k views
5 votes
Create class SavingsAccount. Use a static variable annualInterestRate 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 annualInterestRate divided by 12- this interest should be added to savingsBalance. Provide a static method setInterestRate that sets t

User Tinggo
by
4.5k points

1 Answer

4 votes

Answer:

Class SavingsAccount( ):

annual_interest_rate

def.__init__(self, savings_balance):

self.savingsBalance = savings_balance

def calculatMonthlyInterest( ):

self.savingsBalance += (self.savingsBalance * annual_interest_rate) /12

return self.savingsBalance

def setInterestRate_(self, value):

self.annual_interest_rate = value

Step-by-step explanation:

The python class above is used to create a savings account data for a customer, with methods to change the static interest rate and to calculate the monthly interest rate.

User Zhana
by
5.0k points