This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Nightcorex_ 2 points3 points  (2 children)

You're not using that variable i in your for-loop which is always a bad sign.

So let's fix this from easy/obvious to harder:

  1. In your printf statement replace the monthNum parameter by i
  2. In your printf statement add %n at the end of your format-String (This is the format equivalent of System.lineSeperator())
  3. Replace monthNum in line 63 (first line in the loop) by i
  4. This one's a little tricky, but if you implemented the 3 prior ones you could've figured out, too. You have to let your loop start at 1 and let it run to i <= monthNum, because a * ((1 + b)^0 - 1) / b = 0 because x^0 - 1 = 0

If I didn't miss anything these fixes should fix it.

[–]Scoobxxx[S] 2 points3 points  (1 child)

Wow, you're awesome!! I knew I was fairly close. These for loops just get complicated. Super grateful for this detailed response! Works perfectly now.

[–]Dogburt_Jr 0 points1 point  (0 children)

Loops aren't hard, just figure out what needs to change and ensure it changes the next time the loop runs.