Focus on the big picture, get a savings account with a good interest rate and try and set aside a certain amount of money each month. Even if you’re only putting in $50 a month, it still adds up over the course of a few years. Figuring out just how much you’ll have put into saving, but figuring out how much you’ll have made from interest is somewhat more time consuming, so here’s a simple way to figure out just how much money you might save over an extended period of time.
Savings growth calculator after the jump.
function calculate(form) { var startVal = eval(form.startVal.value) * 1.0; var addVal = eval(form.addVal.value) * 1.0; var years = eval(form.years.value) * 1.0; var frequency = eval(form.frequency.value); var compounded = eval(form.compounded.value); var interest = eval(form.interest.value); if (interest >= 1) { interest /= 100; } var ratePerCompound = interest / compounded;
var periods = frequency * years; var compoundPeriods = compounded * years; var compoundsPerPeriod = compoundPeriods / periods;
var earnedInterest = 0; var balance = startVal; var compoundsDone = 0;
for(var i = 0; i < periods; i++) { var compoundsToDo = Math.floor(i * compoundsPerPeriod) - compoundsDone; for(var j = 0; j < compoundsToDo; j++) { var thisInterest = (balance * ratePerCompound); balance += thisInterest; earnedInterest += thisInterest; compoundsDone++; } balance += addVal; } form.endBalance.value = formatDollars(balance); form.depositTotal.value = formatDollars(periods * addVal); form.interestTotal.value = formatDollars(earnedInterest); } function formatDollars(num) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) { num = "0"; } sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) { cents = "0" + cents; } for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) { num = num.substring(0,num.length-(4*i+3))+',' + num.substring(num.length-(4*i+3)); } return (((sign)?'':'-') + '$' + num + '.' + cents); }
Leave a Reply
You must be logged in to post a comment.