CGI Version --------------------- #!/usr/bin/perl -w use strict; use warnings; my ( $totalinterest, $totaldue, $monthlypayment, $round ); use CGI qw/:standard/; print header, start_html(), start_form, "Principle (amount due): ", textfield('principle'), p, "Interest (as a decimal): ", textfield('interest'), p, "Duration (in months): ", textfield('duration'), p, submit, end_form, hr; chomp( my $principle = param('principle') ); chomp( my $interest = param('interest') ); chomp( my $duration = param('duration') ); if ( $principle && $interest && $duration ) { # if (param('principle') && param('interest') && param('duration')) { print "\n---------------------------
"; $totalinterest = $principle * $interest; print "Total interest: \$$totalinterest
"; $totaldue = $totalinterest + $principle; print "Total due: \$$totaldue
"; $monthlypayment = $totaldue / $duration; $round = sprintf "%.2f", $monthlypayment; print "Monthly price: \$$round
"; print "---------------------------

"; print "How we did it:
"; print "Actual equation: (principle * interest + principle) / months
"; print "Your equation: ($principle \* $interest \+ $principle) \/ $duration
"; print "Step one: ($totalinterest \+ $principle) \/ $duration
"; print "Step two: ($totaldue) \/ $duration
"; print "Step three: \$$round"; hr; } else { print "Something was missing!
"; } print end_html();