title: Class method.. Print the monthly interest amount. Python
body: <p>I am making a program that uses the class Account to print the monthly interest amount of accountA, among other things. I am having problems with getting the getMonthlyInterestRate() and getMonthlyInterest definitions to work out. Here is the program thus far:</p>
  
  <p>Account.py</p>
  
  <pre><code>class Account:
      def __init__(self,id=0,balance=100.0,annualInterestRate=0.0):
          self.__id=id
          self.__balance=balance
          self.__annualInterestRate=annualInterestRate
      def getId(self):
          return self.__id
      def getBalance(self):
          return self.__balance
      def getAnnualInterest(self):
          return self.__annualInterestRate
      def setId(self,newid):
          self.__id=newid
      def setBalance(self,newbalance):
          self.__balance=newbalance
      def setAnnualInterestRate(self,newannualInterestRate):
          self.__annualInterestRate=newannualInterestRate
      def getMonthlyInterestRate(self,getAnnualInterest):
          return(getAnnualInterest(self)/12)
      def getMonthlyInterest(self,getBalance,getMonthly):
          return(getBalance(self)*getMonthlyInterestRate(self))
  
      def withdraw(self,amount):
          if(amount&lt;=self.__balance):
              self.__balance=self.__balance-amount
      def deposit(self,amount):
          self.__balance=self.__balance+amount
      def __str__(self):
          return "Account ID : "+str(self.__id)+" Account Balance : "+str(self.__balance)+" Annual Interest Rate : "+str(self.__annualInterestRate)
  </code></pre>
  
  <p>next</p>
  
  <p>file test.py</p>
  
  <pre><code>from Account import Account
  
  def main():
      accountA=Account(0,100,0)
      accountA.setId(1234)
      accountA.setBalance(20500)
      accountA.setAnnualInterestRate(0.375)
      print(accountA.__str__())
      accountA.withdraw(500)
      accountA.deposit(1500)
      print(accountA.__str__())
      print(accountA.getMonthlyInterest(accountA.getBalance(),accountA.getAnnualInterest())) 
  main()
  </code></pre>
  
  <p>I cannot figure out how to make the getMonthlyInterestRate() and getMonthlyInterest() defintions to work out to be able to put out the right output, which is:</p>
  
  <pre><code>Account ID :  1234 Account Balance :  20500 Annual Interest Rate :  0.375
  
  Account ID :  1234 Account Balance :  21500 Annual Interest Rate :  0.375
  
  Monthly Interest Amount :  671.875
  </code></pre>
  
  <p>mine always comes out with the error statement:</p>
  
  <pre><code>Account ID : 1234 Account Balance : 20500 Annual Interest Rate : 0.375
  Account ID : 1234 Account Balance : 21500 Annual Interest Rate : 0.375
  Traceback (most recent call last):
    File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 13, in &lt;module&gt;
    File "C:\Program Files (x86)\Wing IDE 101 4.1\src\debug\tserver\_sandbox.py", line 12, in main
    File "C:\Users\Meagan\Documents\University\2nd Year\Cmput 174\Account.py", line 21, in getMonthlyInterest
      return(getBalance(self)*getMonthlyInterestRate(self))
  builtins.TypeError: 'int' object is not callable
  </code></pre>
  
  <p>this is what i should make:</p>
  
  <ul>
  <li><p>a method named getMonthlyInterestRate() that returns the monthly interest rate.</p></li>
  <li><p>a method named getMonthlyInterest() that return the monthly interest amount. The monthly interest amount can be calculated by using balance * monthly interest rate. The monthly interest rate can be computed by dividing the annual interest rate by 12.</p></li>
  </ul>
  
  <p>everything else in the program is correct except for those two definitions and the last print statement. Any help would be appreciated. Thanks.</p>