0

Making a compound interest calculator and it doesn't function properly

Hey y'all Ive been trying to make a compound interest calculator and the results it's been giving me seems to be wrong. Here's the code p_principal_amount = float(input("Enter the principal amount: ")) r_interest_rate = float(input("Enter the annual nominal interest rate: ")) n_compound_per_year = float(input("Enter number of time interest is paid out per year: ")) t_number_of_years = float(input("Enter calculation period: ")) a_result = p_principal_amount*(1.0+(r_interest_rate/n_compound_per_year))**n_compound_per_year*t_number_of_years print(a_result) This is the formula for compound interest: A = P(1+R/N)^NT I have no idea what I'm doing wrong. When I input principal amount as 100, interest rate as 2%, (so I input 0.02) compound per year as 12, number of years as 2, it spits out 200 or something Help pls

27th Dec 2018, 5:23 AM
Perryech Zx
Perryech Zx - avatar
2 ответов
+ 4
Use parentheses: a = p*(1+r/n)**(n*t)
27th Dec 2018, 5:38 AM
Diego
Diego - avatar
0
Diego Acero shit i missed that. love you!
27th Dec 2018, 5:41 AM
Perryech Zx
Perryech Zx - avatar