class Mortgage:
def __init__(self, loan, rate, months):
self.loan = loan
self.rate = rate
self.months = months
self.payment = self.findPayment(loan, rate, months)
self.legend = None
def findPayment(self, loan, rate, months):
return loan * ((rate * (1 + rate) ** months) / ((1 + rate) ** months - 1))
m1 = Mortgage(100000, 0.01, 36)
print("The Mortgage is {}, Loan is {}, Months is {}, Rate is {:.2f}, Monthly payment is {:.2f}".format(m1.legend, m1.loan, m1.months, m1.rate, m1.payment))
m2 = Mortgage(100000, 0.01, 120)
print("The Mortgage is {}, Loan is {}, Months is {}, Rate is {:.2f}, Monthly payment is {:.2f}".format(m2.legend, m2.loan, m2.months, m2.rate, m2.payment))