📅  最后修改于: 2022-03-11 14:45:40.520000             🧑  作者: Mango
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