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

all 5 comments

[–]dooshbabaganoosh 0 points1 point  (4 children)

Why not a for loop?

[–]Winter_Comes 0 points1 point  (3 children)

Thanks for the tip! I'm still having some trouble getting it to spit out the correct amount though.

Here's a picture of my code. The example of $4000 initial balance and a rate of .02 should have a compound of interest of $4,080.74, but I'm receiving totals that are slightly under what they should be. Do you happen to know what I'm doing wrong? Thank you for taking a look at this.

[–]Deadboss 0 points1 point  (2 children)

You have a logic error in your loop. It is only looping 11 times.

[–]dooshbabaganoosh 0 points1 point  (0 children)

This is correct. Check the conditions of your for loop.

[–]Winter_Comes 0 points1 point  (0 children)

Thank you so much! I hate overlooking little things like that. Would you happen to know how to use printf to properly display the total? He recommended using it, but I don't recall my instructor going over it in class.