Not sure what is happening but i cant get the program to print the results. The objective is to design a program where i can find out how many months are required to pay off a loan and how much total interest is paid. Also to prevent from overpaying on the loan if the payment is more than the principal. Any help is appreciated:
principal = float(input("Principal-------- "))
annual_interest = float(input("Annual Interest-- "))
monthly_payment = float(input("Monthly Payment-- "))
interest_month = (annual_interest/12)/100
months = 0
actual_payment = 0
total_payment = 0
interest_total = 0
interest_calc = interest_month*principal
interest_total = interest_calc+interest_total
if monthly_payment<interest_total:
print()
print("Loan Not Approved.")
else:
interest_calc = 0
interest_total = 0
while principal >= 0:
months= months + 1
interest_calc = interest_month * principal
interest_total= interest_calc + interest_total
actual_payment= monthly_payment - interest_calc
if actual_payment > principal:
actual_payment = principal
total_payment = actual_payment + total_payment
principal = principal - actual_payment
print()
print("Months : ",months)
print("Interest : $%.2f"%(interest_total))
Aucun commentaire:
Enregistrer un commentaire