purchaseAmount=260000
downPayment=.20
loanLength=30
interestRate=0.052
compoundedMonthly=12
refinancedInterestRate=0.033
def monthlyPayments(p, l, i, c):
n=l*c
r=i/c
M=p*r*(((1+(r))**(n))/(((1+(r))**(n))-1))
return M
def compoundPrincipal(p, l, i, c):
n=l*c
r=i/c
M=p*r*(((1+(r))**(n))/(((1+(r))**(n))-1))
A=M*l*c
return A
def outstandingBalance(p, l, i, c, t):
n=l*c
m=t*c
r=i/c
O=p*(((1+r)**(n))-((1+r)**(m)))/(((1+r)**(n))-1)
return O
originalMonthlyPayments=monthlyPayments((purchaseAmount-purchaseAmount*downPayment),loanLength,interestRate,compoundedMonthly)
originalOutstandingBalance=outstandingBalance((purchaseAmount-purchaseAmount*downPayment),loanLength,interestRate,compoundedMonthly, 10)
originalPrincipal=compoundPrincipal((purchaseAmount-purchaseAmount*downPayment),loanLength,interestRate,compoundedMonthly)
refinancedMonthlyPayments=monthlyPayments(originalOutstandingBalance,loanLength,refinancedInterestRate,compoundedMonthly)
refinancedPrincipal=compoundPrincipal(originalOutstandingBalance,loanLength,refinancedInterestRate,compoundedMonthly)
print(" ORIGINAL LOAN", '\n', "-------------------------", '\n', '\n')
print("Loan amount: $", round(purchaseAmount-(downPayment*purchaseAmount)), '\n')
print("Loan term (years):", loanLength, '\n')
print("Interest rate: ", round(interestRate*100, 2), "%", '\n')
print("Monthly payments: $" ,round(originalMonthlyPayments, 2), '\n')
print("Principal: $",round(purchaseAmount-(downPayment*purchaseAmount)), '\n')
print("Total interest: $", round(originalPrincipal-(purchaseAmount-(downPayment*purchaseAmount)), 2), '\n')
print("Mortgage total: $", round(originalPrincipal, 2), '\n', '\n')
print("Outstanding balance after 10 years: $", round(originalOutstandingBalance, 2), '\n', '\n')
print(" REFINANCED LOAN", '\n', "-------------------------", '\n', '\n')
print("Loan amount: $", round(originalOutstandingBalance, 2), '\n')
print("Monthly payments: $" ,round(refinancedMonthlyPayments, 2), '\n')
print("Loan term (years):", loanLength, '\n')
print("Interest rate: ", round(refinancedInterestRate*100, 2), "%", '\n')
print("Monthly payments: $" ,round(refinancedMonthlyPayments, 2), '\n')
print("Principal: $",round(originalOutstandingBalance, 2), '\n')
print("Total interest: $", round((refinancedPrincipal-originalOutstandingBalance), 2), '\n')
print("Mortgage total: $", round(refinancedPrincipal, 2), '\n', '\n')