#!/usr/local/bin/perl # $args = $ENV{'QUERY_STRING'}; if (length($args) < 3) { print<Simple Loan Payment Calculator

Simple Loan Payment Calculator


Enter the values and I will tell you the payment. The loan can be a mortgage, car loan, or any other simple interest amortization over a fixed time with fixed monthly payments.


Principal
Interest
Number of Years:

Hugh Chou EOF } else { #($pmin,$pmax,$imin,$imax,$term) = split("&",$args); @v = split("&",$args); $tbl = "N"; for ($i=0; $i<=$#v; $i++) { ($key,$val) = split("=",@v[$i]); $val =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; $val =~ s/,//g; $aa{$key} = $val; } $yrs = $aa{"yrs"}; $int = $aa{"int"}; $amt = $aa{"amt"}; $tt = $yrs * 12; print "Content-type: text/html\n\n"; print "Your Monthly Payment\n"; print "\n"; print "

Your Monthly Payment for $yrs Years

"; printf ("

for an Interest Rate of %6.3f %%

",$int); printf ("

on a Loan Amount of \$ %9.2f:

",$amt); $mi = $int / 1200; $temp = (1.0 / (1 + $mi) ** $tt); if ($temp < 1) { $pmt = $amt * $mi / (1 - $temp); } else { $pmt = $amt / $tt; } printf ("

\$ %9.2f a Month

",$pmt); print "
Hugh Chou
\n"; }