Command Line Version ----------------------- #!/usr/bin/perl -w use strict; use warnings; my ( $totalinterest, $totaldue, $monthlypayment, $round ); print "Principle:"; chomp( my $principle = ); while ( $principle !~ /^-?\.?\d+(?:\.\d+)?$/ ) { print "Number you supplied did not look like a real number.\n"; print "Only numbers and decimals are allowed, no commas!\n\n"; print "Principle:"; chomp( $principle = ); } print "Interest (as a decimal):"; chomp( my $interest = ); while ( $interest !~ /^-?\.?\d+(?:\.\d+)?$/ ) { print "Number you supplied did not look like a real number.\n"; print "Only numbers and decimals are allowed, no commas!\n\n"; print "Interest (as a decimal):"; chomp( $interest = ); } print "Duation (in months):"; chomp( my $duration = ); while ( $duration !~ /^-?\.?\d+(?:\.\d+)?$/ ) { print "Number you supplied did not look like a real number.\n"; print "Only numbers and decimals are allowed, no commas!\n\n"; print "Interest (as a decimal):"; chomp( $duration = ); } print "\n---------------------------\n"; $totalinterest = $principle * $interest; print "Total interest: \$$totalinterest\n"; $totaldue = $totalinterest + $principle; print "Total due: \$$totaldue\n"; $monthlypayment = $totaldue / $duration; $round = sprintf "%.2f", $monthlypayment; print "Monthly price: \$$round\n"; print "---------------------------\n\n"; print "How we did it:\n"; print "Actual equation: (principle * interest + principle) / months\n"; print "Your equation: ($principle \* $interest \+ $principle) \/ months\n"; print "Step one: ($totalinterest \+ $principle) \/ months\n"; print "Step two: ($totaldue) \/ months\n"; print "Step three: $round";