-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoan.py
45 lines (32 loc) · 1.33 KB
/
Loan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Loan:
def __init__(self, annualInterestRate=2.5,
numberOfYears=1, loanAmount=1000, borrower=" "):
self.__annualInterestRate = annualInterestRate
self.__numberOfYears = numberOfYears
self.__loanAmount = loanAmount
self.__borrower = borrower
def getAnnualInterestRate(self):
return self.__annualInterestRate
def getNumberOfYears(self):
return self.__numberOfYears
def getLoanAmount(self):
return self.__loanAmount
def getBorrower(self):
return self.__borrower
def setAnnualInterestRate(self, annualInterestRate):
self.__annualInterestRate = annualInterestRate
def setNumberOfYears(self, numberOfYears):
self.__numberOfYears = numberOfYears
def setLoanAmount(self, loanAmount):
self.__loanAmount = loanAmount
def setBorrower(self, borrower):
self.__borrower = borrower
def getMonthlyPayment(self):
monthlyInterestRate = self.__annualInterestRate / 1200
monthlyPayment = \
self.__loanAmount * monthlyInterestRate / (1 - (1 / (1 + monthlyInterestRate) ** (self.__numberOfYears * 12)))
return monthlyPayment
def getTotalPayment(self):
totalPayment = self.getMonthlyPayment() * \
self.__numberOfYears * 12
return totalPayment