// $Id: mortgage_payment.js,v 1.1 2005/03/04 23:53:32 mzimniak Exp $ // // $Log: mortgage_payment.js,v $ // Revision 1.1 2005/03/04 23:53:32 mzimniak // initial upload // // function compute_payment(balance, rate, num_payments, pay_per_year) { var payment; if (rate <= 0.0) { payment = balance * 1.0/(num_payments); } else { payment = balance * (rate/100.0/pay_per_year) / (1.0 - Math.pow(1.0 + rate/100.0/pay_per_year, -num_payments)); } return Math.floor(payment * 100.0 + 0.5)/100.0; }