In: Computer Science
Perl Programming
Please write a simple to understand Perl script that computes compound interest, based on input from user for P, n, r and t.
Code Screenshot :

Executable Code:
#Prompting the
user for inputs
print "Enter the principal amount : : ";
$P = <> ;
print "Enter number of times interest is applied in a year:
";
$n = <> ;
print "Enter the rate of interest : ";
$r = <> ;
print "Enter the number of years: ";
$t = <> ;
#Calculating
the compound Interest and final amount
for ($x = 1; $x <= $t; $x = $x + 1) {
   for ($y = 1; $y <= $n; $y = $y + 1) {
       $interest = $P * ($r / ($n *
100));
       $P = $P + $interest;
   }
}
#Printing the
result
print sprintf("\nFinal Balance is \$%.3f\n", $P);
Sample Output :

Please comment
below if you have any queries.