I’ve been building a financial calculator that lets you enter a monthly payment, an interest rate level and an overall debt level, then tells you how long it’ll take to pay off the loan and how much interest you’ll end up paying. It’s fairly self-explanatory, I think, and interesting to read.
First off, here’s the JavaScript:
<script type="text/javascript"> <!-- // Script written by Dave Taylor based on some math suggested by // Bennett Haselton @ Peacefire.org. Thanks Bennett! function centNotation(value) { // return the value in normalized dollars.cents notation dollars = Math.floor(value); // chop floating point portion cents = Math.floor((value % 1) * 100); // and chop everything else if (cents < 10) cents = "" + cents + "0"; return(dollars + "." + cents); }