#!/usr/local/bin/perl # Nominal & Effective Interest Rates print "Content-type: text/html\n\n"; $args = $ENV{'QUERY_STRING'}; $args =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; $args =~ s/[ ,+]//g; if (length($args) < 2) { print<Nominal and Effective Interest Rates

Nominal and Effective Interest Rates

Calculate what rates are necessary to achieve a desired future value amount given a present value amount and the time period over which to compound your investment.
  • Future Value
  • Present Value
  • Total Years
  • Compound Periods Per Year
  • Formtext } else { print "Results for Nominal and Effective Interest Rates\n"; print "

    Results for Nominal and Effective Interest Rates

    \n"; @f = split("&",$args); for ($i=0; $i<=$#f; $i++) { $rec = @f[$i]; if ($rec =~ /^fv/) { $fv = substr($rec,3); } if ($rec =~ /^pv/) { $pv = substr($rec,3); } if ($rec =~ /^yr/) { $yr = substr($rec,3); } if ($rec =~ /^py/) { $py = substr($rec,3); } } $np = $yr * $py; $nr = ($py * ($fv / $pv) ** (1 / $np) - $py) * 100.0; $er = (($fv / $pv) ** ($py / $np) -1) * 100.0; printf("To accumulate a future balance of : \$ %11.2f",$fv); printf("
    Given a current amount of : \$ %11.2f",$pv); print "
    over $yr years, compounded $py times a year ($np total "; print "periods)\n"; print "
    The following rates are required:
    \n"; printf("
  • Required Nominal rate is %11.4f %% \n",$nr); printf("
  • Required Effective is %11.4f %% \n",$er); }