mikefallen
02-06-2012, 03:11 AM
I'm taking an introductory course to python and I'm having really frustrating time as this is very simple and i have done programming much more complex and just getting really frustrated on being hung up on this.
So my assignment is to create a calculator that does APR interest using the formulahttp://research.cs.queensu.ca/home/cisc101f/Winter2012/Assn1/Equation.JPG
Where A is the monthly payment, P is the total amount borrowed (the principal), n is the number of months for repayment and i is the monthly interest rate. You can calculate the monthly interest rate by dividing the annual interest rate ("APR") by 12.
For example, to borrow $30,000 (P) for a 10 year term (n = 120) with an APR interest rate of 6% (i = 0.06 / 12 = 0.005), A calculates to be $333.06 - the monthly payment. The total interest paid over 10 years (always depressing!) = 120 * $333.06 - $30,000 = $9,967.38.
def main():
print("****************************************")
print("Mortgage Calculator v1.0")
print("****************************************")
print("")
principal = float(input("Principal Amount "))
years = int(input("Input number of years "))
interest = float(input("Input interest percentage "))
interest = (interest/100)/12
months = years*12
monthly_payments = principal*interest/1-(1+interest)**-months
print(apr)
print("After", Years, "years at", format(interest, '.0%'), " interest ", "total is", format(Total, '.2f'))
print("Monthly payments will be", monthly_payments)
print("Total interest will amount to", format(total_interest, '.2f'))
main()
So my assignment is to create a calculator that does APR interest using the formulahttp://research.cs.queensu.ca/home/cisc101f/Winter2012/Assn1/Equation.JPG
Where A is the monthly payment, P is the total amount borrowed (the principal), n is the number of months for repayment and i is the monthly interest rate. You can calculate the monthly interest rate by dividing the annual interest rate ("APR") by 12.
For example, to borrow $30,000 (P) for a 10 year term (n = 120) with an APR interest rate of 6% (i = 0.06 / 12 = 0.005), A calculates to be $333.06 - the monthly payment. The total interest paid over 10 years (always depressing!) = 120 * $333.06 - $30,000 = $9,967.38.
def main():
print("****************************************")
print("Mortgage Calculator v1.0")
print("****************************************")
print("")
principal = float(input("Principal Amount "))
years = int(input("Input number of years "))
interest = float(input("Input interest percentage "))
interest = (interest/100)/12
months = years*12
monthly_payments = principal*interest/1-(1+interest)**-months
print(apr)
print("After", Years, "years at", format(interest, '.0%'), " interest ", "total is", format(Total, '.2f'))
print("Monthly payments will be", monthly_payments)
print("Total interest will amount to", format(total_interest, '.2f'))
main()