I need to write a mortgage calculator program that will find the amount of a monthly mortgage payment for a loan.
# Get information from user
print 'CALCULATOR FOR MORTGAGE LOANS'
loan_str = raw_input ("Amount of loan:")
loan = eval(loan_str)
years_str = raw_input("Number of years:")
years = eval(years_str)
rate_str = raw_input ("Annual percentage rate:")
rate = eval(rate_str)
# Use formula and print results
print '$',loan, 'at', rate,'%','for', years, 'years'
print 'Monthly Payment:', '$',loan * rate * 1 + rate ** 12 / 1 + rate ** -1
So far I have gotten the information from the user and converted it to numbers. What I need to do is:
- I was advised to not use "12" in the formula for months but rather total number of months power and I'm not sure how to implement that..formula is here
- Convert to months and decimals (confused with this)
- Then apply formula
- Then print results
Help is greatly appreciated!