|
Calculators for Your Web Site : Loan Payment Calculator
By Stephen Bucaro
The goal for any Web site owner is to attract visitors to their Web site and
get them to stick around. This is referred to as making your Web site "sticky".
One way to do this is to provide useful features like online calculators.
In this article, I provide you with Java Script code for a loan payment
calculator. The process of designing a loan payment calculator, like any
calculator, can be divided into the five steps listed below.
- Acquire the proper formula.
- Design an html form to get input values from the user.
- Code the basic calculation function.
- Add Code to format the output to the user.
- Add Code to handle errors.
Click here
to view the working Loan Payment Calculator
The Loan Payment Formula
The loan payment formula is well known and can be found in many mathematics
textbooks and at many locations on the Web. The formula is shown below.
monthlyRate
monthlypayment = loanAMT x ----------------------------------
1 - ( 1 + monthlyRate) ^ -numPayments
loanAMT = The initial amount of the loan.
monthlyRate = The monthly interest (the annual interest rate / 12).
numPayments = number of payments (made monthly).
The important point about this formula is that it calculates the payment with
compound interest. With compound interest you pay interest not only on the
principal, but also on the accumulated interest. Yearly Compounding is the
number of times per year that the compound interest calculation is performed.
Interest is usually compounded monthly.
• In case you're not familiar with the syntax, ^ -numPayments
means raise it to the negative power of the number of payments.
|