You are on page 1of 1

Code:

amount=input("Enter the investment amount: ")

amount=float(amount)

n=input("Enter the number of years: ")

n=int(n)

r=input("Enter the rate(in %): ")

r=float(r)

v=amount

print("Year\t\tStarting balance\tInterest\t\tEnding balance")

for i in range(1,n+1):

ins=amount*r/100

print(i,"\t\t",format(amount,'.2f'),"\t\t",format(ins,'.2f'),"\t\t",format((amount+ins),'.2f'))

amount=amount+ins

print("Ending balance:",format(amount,'.2f'))

v=amount-v

print("Total interest:",format((v),'.2f'))

output:

You might also like