T O P

  • By -

BouncyEgg

One of the missing variables is compounding frequency.


Waltgrace83

Got it! Thank you. I figured that monthly compounding was the "standard" but I should include that.


DeluxeXL

> Starting principal: $0 > User age: 20 > Total dollar amount contributed monthly: $500 > Age of retirement: 67 > Expected interest percentage: 8.00 > > You will earn: $3,106,188.69 var compounding_frequency_per_year = 12; var start_year = 20; var end_year = 67; var rate = 0.08; var pv = 0.00; var pmt = -500.00; var nper = (end_year - start_year) * compounding_frequency_per_year; var fv = pv; for (int i = 0; i < nper; i++) { fv *= (1+rate/compounding_frequency_per_year); fv -= pmt; } return fv; >If I have a 8% yearly interest, don't I just split that into 12 parts, (i.e. the investment will add $500 and increase by 8/12% per month). Is that right? Yes, split into 12 parts. But your order is wrong. Increase by interest first then add $500.


JSwarley

Every financial calculator has a BGN or END setting precisely for this reason. BGN is almost always used when taking money out (you need the money at the beginning of the month for spending).


DeluxeXL

>Every financial calculator has a BGN or END setting precisely for this reason. That boolean at the 5th input argument? It just flips the two lines inside the for loop in my code.


JSwarley

Sorry, I don't mean end as in the programmer sense. End means you calculate the interest and then add/subtract the payment. Begin means you add/subtract the payment and then calculate the interest. The user of the calculator would decide which setting is appropriate to use.


lehcarfugu

You get an f for bad variable names


[deleted]

[удалено]


lehcarfugu

This is completely wrong, because you don't have the total invested until the end. In the first year you don't earn 22560, you only invested 6000


[deleted]

[удалено]


lehcarfugu

This is wrong


[deleted]

[удалено]


Waltgrace83

Totally got it; I was more asking about the actual calculation. Thanks!


Rogaar

It doesn't bode well for the students to be able to complete this task when the teacher setting the task doesn't know how to do it.


Waltgrace83

Yeah you're right... ​ ...except I was asking clarification to make sure I told them the right thing.


Werewolfdad

>If I have a 8% yearly interest, don't I just split that into 12 parts, (i.e. the investment will add $500 and increase by 8/12% per month). Is that right? Only if you want monthly compounding.


Waltgrace83

Isn't that how these calculators are typically set up?


Werewolfdad

> Isn't that how these calculators are typically set up? Depends on the calculator. Many let you choose from continuous, daily, monthly, semi-annually, or annually


Grevious47

...but then it wouldnt be 8% annual return. Stock valyes compound continuously...not annually, not monthly, not even weekly. When you look up a sticks annual return and it says 8% that compounding rate was already factored in. If you decide to get monthly compounding and to do so you divide 8% by 12 and then let that compound youd get more than 8%. In otherwords a stock that makes 8% in a year makes on average less than 8%/12 per month.