Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: COMPOUND INTEREST CACULATOR : PYTHON PROGRAMMING

Friday, September 24, 2021

COMPOUND INTEREST CACULATOR : PYTHON PROGRAMMING


If the principal is P and the rate of compound interest is r% per annum and the interest is compounded k times in a year, then the amount after n years is given by the formula


If k = 1, the interest is payable yearly, for k =2 the interest is payable half-yearly and for k=4 the interest is payable quarterly. Below is the program which uses above formula to calculate the final amount.

PYTHON CODE



principal = float(input("Enter the principal value:"))
rateOfInterest = float(input("Enter the rate of interest:"))
numberOfMonths = int((input("Enter the period in months:")))
frequency =int(input("Enter the number of times the the interest is compunded (yearly=1, half-yearly=2, quarterly =4,..):"))
finalAmount = 0.0
finalAmount += principal*(1+(rateOfInterest/frequency)/100)**(frequency*(numberOfMonths/12))
print("The final amount is"round(finalAmount,2))



No comments:

Post a Comment