#!/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?

How much house can you afford?

Annual Income
Monthly Debt (Car payments, credit cards, student loan payment etc.)
Cash in hand for down payment
Property tax rate (1% = \$1000/yr for 100K house)
Home Insurance rate (0.5% = \$500/yr for 100K house)
Interest Rate (%)
Length of Loan (years)

ThisWasReallyFunkedCodeMan } else { print qq!This is an estimate of what you can afford!; print qq!!; print qq!

Here are some estimates of what you can afford:

!; print qq!

!; @arga = split("&",$arg); for ($i=0; $i<=$#arga; $i++) { ($key,$val) = split("=",@arga[$i]); $aa{$key} = $val; } $r1 = 28; $r2 = 36; $mi = $aa{"ai"}/12; $c1 = $mi * $r1 / 100; $c2 = ($mi * $r2 / 100) - $aa{"md"}; if ($c1 < $c2) { 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.

!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!
House value:!; printf(" \$ %7.2f\n",$house); print qq!
Loan value:!; printf(" \$ %7.2f\n",$loan); print qq!
!; print qq!Monthly Principal+Interest:!; printf(" \$ %7.2f\n",$loan/$amv); print qq!
!; print qq!Monthly Prop Tax+Insurance:!; printf(" \$ %7.2f\n",$house*$piti_ov/1200); print qq!
Down Payment:!; printf(" %5.2f %%\n",$dpp); print qq!
Loan To Value(LTV):!; printf(" %5.2f %%\n",$ltv); print qq!
!; 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!!; print qq!!; #print qq!!; print qq!!; #print qq!!; print qq!!; #print qq!!; print qq!!; #print qq!!; print qq!!; #print qq!!; print qq!!; #print qq!!; print qq!
House value:$ $house!; print qq!!; printf(" \$ %7.2f\n",$house); print qq!
Loan value:$ $loan!; print qq!!; printf(" \$ %7.2f\n",$loan); print qq!
!; print qq!Monthly Principal+Interest:$ $loan/$amv!; print qq!!; printf(" \$ %7.2f\n",$loan/$amv); print qq!
Monthly Prop Tax+Insurance:$house*($piti_ov-0.5)/1200!; print qq!!; printf(" \$ %7.2f\n", $house*($piti_ov-0.5)/1200); print qq!
Down Payment:$dpp!; print qq!!; printf(" %5.2f %%\n",$dpp); print qq!
Monthly PMI:$ $house*$pmi/1200!; print qq!!; printf(" \$ %7.2f\n",$house*$pmi/1200); print qq!
!; print qq!
!; printf ("

That's an extra %4.2f %% of your loan each year

",$pmi); } DPTooLowTxt: if ($dpp<3 && $aa{"ty"} =~ /Conv/ ) { print<

Your down payment is under 3%

Many conservative lenders won't do that except on FHA/VA loans. Look around for a lender willing to accept your lower down payment.

You are relatively income rich but cash poor

You do not have to worry about your income qualifying you for your loan. What limits your house value is simply your down payment of \$ $dp: DPTooLow printf("

With 20%% down (80%% LTV) you can buy a \$ %7d house

\n",$dp*5); printf("

With 10%% down (90%% LTV) you can buy a \$ %7d house

\n",$dp*10); printf("

With 5%% down (95%% LTV) you can buy a \$ %7d house

\n",$dp*20); printf("

With 3%% down (97%% LTV) you can buy a \$ %7d house

\n",$dp*33.3); print< So look for a lender who is willing to give you a high LTV (loan to value).

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< trailer