Skip to content
Advertisement

Looking to get the yearly returns on this total compound interest calculator

I’m really new to Java so please excuse if this isn’t the 100% right way to even write this code.

So I’ve been messing around with this code for about 6 hours now, and I can not for the life of me figure out how to fix this issue:

I have a compound interest calculator that takes user input for the variables of term length, initial amount, and APR. I can get the answer I want if it was just the simple one time calculation, but I really want it to show me the amount increased each year of a term. For example: If the interest is calculated for 10 years, I want it to show me the amount for each year leading up to it. Right now all I get is a static number of 1, or infinity.

How do I get this program to show me the total amount for the term (i.e. the length of the user input investment), broken down per year with the amount shown per year?

The code is:

JavaScript

Any help would be greatly appreciated because I am really out of my depth with this one.

Advertisement

Answer

Just a small change in your calculation logic:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement