Program to calculate compound interest

# Calculate Compound Interest
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate of interest: "))
time = float(input("Enter the time in years: "))
n = int(input("Enter the number of times interest applied per time period: "))

amount = principal * (1 + (rate / (n * 100))) ** (n * time)
compound_interest = amount - principal
print("The compound interest is:", compound_interest)
Output:
Enter the principal amount: 1000
Enter the rate of interest: 5
Enter the time in years: 3
Enter the number of times interest applied per time period: 4
The compound interest is: 161.6179955869992

Leave a Reply

Your email address will not be published. Required fields are marked *