table and amorization charts using tkinter 1

table and amorization charts using tkinter

import math
print("Payment Amount")
p=input()
print("interest value in decimals")
r=input()
print("Loan Period in years")
t=input()
p=float(p)
r=float(r)
t=float(t)
m=(p*(r/12)*(math.pow(1+r/12,12*t)))/(math.pow(1+r/12,12*t)-1)
print("Loan paymnet amount monthly is: $"+str(m))
print("PaymentNumber\tPaymnetAmount\tPrincipalAmountPaid\tInterestAmountPaid\tLoanOutstandingBalance")
month=12*t
month=int(month)
PaymentAmount=p
LoanOutstandingBalance=p
for i in range(1,month+1):
    
    InterestAmountPaid=r/12*PaymentAmount
    PrincipalAmountPaid=m-InterestAmountPaid
    LoanOutstandingBalance=PaymentAmount+InterestAmountPaid-m
    print(str(i)+"\t\t$"+str(round(PaymentAmount,2))+"\t\t$"+str(round(PrincipalAmountPaid,2))+"\t\t$"+str(round(InterestAmountPaid,2))+"\t\t$"+str(round(LoanOutstandingBalance,2)))
    PaymentAmount=LoanOutstandingBalance  

Here is what the above code is Doing:
1. It is asking the user to input the loan amount, interest rate and loan period.
2. It is converting the input values to float.
3. It is calculating the monthly payment amount using the formula given in the assignment.
4. It is printing the monthly payment amount.
5. It is calculating the number of months in the loan period.
6. It is initializing the PaymentAmount, LoanOutstandingBalance variables to the loan amount.
7. It is looping through the number of months in the loan period.
8. It is calculating the InterestAmountPaid, PrincipalAmountPaid and LoanOutstandingBalance using the formulas given in the assignment.
9. It is printing the values of PaymentNumber, PaymentAmount, PrincipalAmountPaid, InterestAmountPaid and LoanOutstandingBalance.
10. It is updating the PaymentAmount to the LoanOutstandingBalance.

Similar Posts