How to get Python Compound Interest Calculator to give the correct answer?
<p>I've run into the issues of my Compound Interest Calculator giving the wrong calculation when you input the principal, compounded interest (yearly, monthly, etc..), interest rate (0.03, etc...), and the number of years.</p>
<p><a href="https://stackoverflow.com/questions/34948946/final-p-1-r-n-nt-typeerror-unsupported-operand-types-for">Previous question's link</a></p>
<p>So from the previous code, I removed <code>p = 10000, n = 12, r = 0.08</code> because it would give a large number when you input different numbers. My hope was it would calculate it with the numbers inputted, but it doesn't.</p>
<pre><code># User must input principal, Compound rate, annual rate, and years.
P = int(input(&quot;Enter starting principle please. &quot;))
n = int(input(&quot;Enter Compound intrest rate.(daily, monthly, quarterly, half-year, yearly) &quot;))
r = float(input(&quot;Enter annual interest amount. (decimal) &quot;))
t = int(input(&quot;Enter the amount of years. &quot;))

final = P * (((1 + (r/n)) ** (n*t)))
#displays the final amount after number of years.
print (&quot;The final amount after&quot;, t, &quot;years is&quot;, final)
# At the moment it is displaying a very random number.

Enter starting principle please. 1000
Enter Compound intrest rate.(daily, monthly, quarterly, half-year, yearly) 1
Enter annual interest amount. (decimal) 0.01
Enter the amount of years. 1
The final amount after 1 years is 1010.0
</code></pre>
<p>The final amount should be <code>1000.10</code>. Not sure what is going on. Trying to see if there is a way to make <code>P, n, r</code> equal the number of user inputs that will result in the correct final answer.</p>