#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
#THIS CODE IS HARSH, EDIT AT YOUR OWN RISK AND DON"T GET YOUR PANTIES IN A BUN
$arg = $ENV{'QUERY_STRING'};
if (length($arg) < 3)
{
print<How much house can you afford?
Here are some estimates of what you can afford:
!;
print qq!
!; printf("We must use the %2d %% amount of \$%8.2f for PITI", $r1, $c1); print " because this value is lower than the amount "; printf("(\$%8.2f) calculated using the %2d %% monthly debt value. ", $c2, $r2); $piti = $c1; } else { printf("
We must use the %2d %% amount of \$%8.2f for PITI\n", $r2, $c2); print " because this value is lower than the amount "; printf("(\$%8.2f) calculated using the %2d %% income only value ", $c1, $r1); printf("To use the lower %2d %% limit, try to keep your monthly", $r1); printf(" debt payments below \$ %8.2f (reduce them by \$ %8.2f) ", $mi * ($r2 - $r1)/100, $aa{"md"} - $mi * ($r2 - $r1)/100); $piti = $c2; } $j = $aa{"ir"}/1200; $yr = $aa{"yr"}; $amv = (1 - (1 + $j)**(-$yr * 12))/$j; printf("Your interest rate of %5.2f %% over $yr years means ",$aa{"ir"}); printf("every dollar you pay each month buys you \$ %7.2f of loan",$amv); $piti_ov = $aa{"hi"} + $aa{"pt"}; printf(". You stated Tax and Insurance would total %5.2f %% the home value", $piti_ov); $dp = $aa{"dp"}; printf(" And with \$ %7.2f to cover your down payment
\n",$dp); $house = 1000; $pmt = $piti; $loan = 1000; for ($i=0; $i<20; $i++) { $ti = $piti_ov/1200 * $house; $loan = ($piti - $ti) * $amv; $house = $loan + $dp; } $dpp = $dp/$house*100; $ltv = ($house-$dp)/$house*100; print qq!Don't forget closing costs and points.
| !;
if ($ltv>80)
{
print " Your down payment is less than 20%! You pay PMI "; $house = 1000; $pmt = $piti; $loan = 1000; if ($aa{"ty"} =~ /Conv/) { $pmi = .32; if ($ltv>=85) { $pmi = .52; } if ($ltv>=90) { $pmi = .78; } if ($ltv>=95) { $pmi = .90; } if ($ltv>=97) { goto DPTooLowTxt; } } else { $pmi = .5; } $piti_ov += $pmi; for ($i=0; $i<20; $i++) { $ti = $piti_ov/1200 * $house; $loan = ($piti - $ti) * $amv; $house = $loan + $dp; } $dpp = $dp/$house*100; print qq!
|
That's an extra %4.2f %% of your loan each year
",$pmi); } DPTooLowTxt: if ($dpp<3 && $aa{"ty"} =~ /Conv/ ) { print<
Better yet get more cash for your down payment. Those low or no interest
loans
from parents, friends and relatives sure come in handy!
DPTooLo2
}
}
print<