xxxxxxxxxx
<?php
function com($prin, $rate, $time, $n){
$amount = $prin * pow((1 + ($rate / $n)), ($n*$time));
return $amount;
}
echo "Enter the principal amount: ";
$prin = (float) trim(fgets(STDIN));
echo "Enter the interest rate: ";
$rate = (float) trim(fgets(STDIN));
echo "Enter the time period: ";
$time = (int) trim(fgets(STDIN));
$n = 12;
$fin_amount = com($prin, $rate, $time, $n);
echo "The final amount after $time years is R" . round($fin_amount, 2);
?>