#! /usr/bin/perl require "cgi-lib.pl"; require "cl-lib.pl"; sub doform { if ($forms) { open(INPUTFORM,"payment/pcinpre.html") || die "Can't open your input form-post. $!\n"; while() { print $_; } close INPUTFORM; } print qq!

!; print qq!
!; print qq!
!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!!; print qq!
(Note: Please enter only numbers)
Loan Amount
Term (in years)
Interest Rate
!; print qq!

!; if ($forms) { open(INPUTFORM,"payment/pcinpost.html") || die "Can't open your input form-post. $!\n"; while() { print $_; } close INPUTFORM; } print qq!


Return to Home Page

! if ($input{c}); } sub Results { if ($forms) { open(INPUTFORM,"payment/pcoutpre.html") || die "Can't open your input form-post. $!\n"; while() { print $_; } close INPUTFORM; } print ""; printf ("", $loanamount); printf ("", ($rate * 100)); printf ("", $term); printf ("", $payment); print "
Loan Amount : \$%-9.0d
Interest Rate : %3.3f\%
Loan Term : %2.0f years.
Payment : \$%-9.2f per month.
"; print qq!
!; print qq!
!; print qq!
!; print qq!!; print qq!!; print qq!!; print qq!!; $rate=$rate*100; print qq!!; print qq!!; print qq!
(Note: Please enter only numbers)
Loan Amount
Term (in years)
Interest Rate
!; if ($forms) { open(INPUTFORM,"payment/pcoutpost.html") || die "Can't open your input form-post. $!\n"; while() { print $_; } close INPUTFORM; } print qq!


Return to Home Page

! if ($input{c}); } sub Process { $numerator = ( $loanamount * ($rate/12)); $denominator = (1 - (1 / (1 + ($rate/12))) ** ($term * 12)); $payment = $numerator / $denominator; } MAIN: { $forms=true; print &PrintHeader; if (&MethGet) { &ReadParse ( *input); &doform; } else { if (! &ReadParse ( *input)) { $in = ""; $in .= "&banana=spiders"; $in .= "&c=abcmortgage"; $in .= "&loanamount_=100000"; $in .= "&term=30"; $in .= "&rate%=8"; @input = split(/&/,$in); foreach $i (1 .. $#input) { ($key, $val) = split(/=/,$input[$i],2); if (index($key,"\%") > $[) { $val = $val * 0.01; $key =~ s/\%//; } if (index($key,"_") > $[) { $val =~ s/\,//; $key =~ s/_//; } $input{$key} .= $val; } } $loanamount = $input {loanamount}; $term = int ($input {term}); $rate = $input {rate}; &Process; &Results; } }