Loan

 avatar
shinta0x01
python
a year ago
975 B
4
Indexable
while True:
    PR = float(input("Input the principal: "))
    IY = float(input("Input the interest year: "))
    NY = int(input("Input the number of year: "))
    if PR < 0 or IY < 0 or NY < 0:
        print("Invalid Input!")
        exit()
    break

NM = (NY * 12)
IM = (IY / 12) / 100
P = (1 + IM) ** NM
Q = (P / (P - 1))
MP = (PR * IM * Q)
NB = PR

print("The amount of the laon (principal): " + str(PR))
print("Interest rate/year (percent): " + str(IY))
print(f"Interest rate/month (percent): {IM:.2f}")
print("Number of years: " + str(NY))
print("Number of months: " + str(NM))
print(f"Monthly Payment: {MP:.2f}")

print(f"Month\t\t Old Balance\t\t Monthly Payment\t\t Interest Paid\t\t Principal Paid\t\t New Balance")
for i in range(NM):

    OB = NB
    IP = OB * IM
    PP = MP - IP
    NB = OB - PP


    print(f"{i+1}\t\t\t {OB:.2f}\t\t\t\t {MP:.2f}\t\t\t\t\t {IP:.2f}\t\t\t\t\t{PP:.2f}\t\t\t\t\t {NB:.2f}")
    OB = NB




Editor is loading...
Leave a Comment