Python question Design a SavingsAccount class that stores a savings account's annual interest rate and balance....

50.1K

Verified Solution

Question

Programming

Python questionDesign a SavingsAccount class that stores a savings account's annual interest rate and balance. The class constructor should accept the amount of the savings account;s starting balance. The class should also have methods for subtracting the amount of a withdraw, adding the amount of a deposit, and adding the amount of monthly interest to the balance. The monthly interest rate is the annual interest rate divided by twelve. To add the monthly interest to the balance, multiply the monthly interest rate by the balance, and add the result to the balance.Test the class in a program that calculates the balance of a savings account at the end of a period of time. it should ask the user for the annual interest rate, the starting balance, and the number of months that have passed since the account was established. A loop should then iterate once for every month, preforming the following:a. ask the user for the amount deposited into the account during the month. use the class method to add this amount to the account balance.b. ask the user for the amount withdrawn from the account during the month. use the class method to subtract this amount from the account balance.c. use the class method to calculate the monthly interest.After the last iteration, the program should display the ending balance, the total amount of deposits, the total amount of withdrawals, and the total interest earned. What I have so far:class SavingsAccount:  def __init__(self,balance):    self.__balance = balance    self.__annualRate = 0    self.__monthInterest = 0  def withdrawl(self, amt):    self.__balance -= amt  def deposit(self, amt):    self.__balance += amt  def set_interestRate(self,rate):    self.__annualRate = rate  #This method calculates mothly interest based on the annual interest rate and adds it to the balance  def mth_interest(self):    self.__monthInterest = self.__annualRate/12 * self.__balance    self.__add_mth_interest(self.__monthInterest)    return self.__monthInterest  def __add_mth_interest(self, interest):    self.__balance += interest  def get_balance(self):    return self.__balance

Answer & Explanation Solved by verified expert
3.8 Ratings (588 Votes)
Thanks for the questionYour class is all good I have written the main function that demonstrates your classHere is the updated code with screenshotclass SavingsAccount def initself balance selfbalance balance selfannualRate 0 selfmonthInterest 0 def withdrawlself amt selfbalance amt def    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students