#!/usr/local/bin/perl # $args = $ENV{'QUERY_STRING'}; print "Content-type: text/html"; print "\n"; if (length($args) < 3) { # # The Form Hasn't Been Submitted. Display Input Form. # 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:

EOF } else { # The form has been submitted, display output. #($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 "Your Monthly Payment\n"; print "\n"; print "

Your Monthly Payment

"; print "If you take a loan for $yrs Years
"; printf ("with an Interest Rate of %6.3f %%
",$int); printf ("for a Loan 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 ("then your payment will be \$ %9.2f a Month!",$pmt); print "
\n"; } print "\n"; print "\n";