Question

In: Computer Science

Perl Programming Please write a simple to understand Perl script that computes compound interest, based on...

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.

Solutions

Expert Solution

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.


Related Solutions

Perl Programming Write a Perl script that computes compound interest balance, A, based on input from...
Perl Programming Write a Perl script that computes compound interest balance, A, based on input from user for P, n, r and t.
Perl is a programming language that can be used on Linux. Write a Perl shell script...
Perl is a programming language that can be used on Linux. Write a Perl shell script named phone.pl that prompts the user to enter first or last or any portion of person’s name, so that can be found the appropriate entry in the phone directory file called “phones”. If the user tries to enter name as the argument on the command line, he/she will get a warning message “You need to provide name when prompted by this script!” If the...
MATLAB please make it simple to understand P4.2.5 Write a script that draws an equilateral triangle...
MATLAB please make it simple to understand P4.2.5 Write a script that draws an equilateral triangle that is partitioned into four smaller equilateral triangles by connecting the midpoints of its sides. The four little triangles should be colored differently.
Simple and compound interest rate 8. Determine the effective interest rate, based on a 15% annual...
Simple and compound interest rate 8. Determine the effective interest rate, based on a 15% annual rate with monthly capitalization: a) effective monthly rate, b) effective quarterly rate, c) semi-annual effective rate, d) annual rate effective. 9. Determine the effective annual interest rate, based on the nominal interest rate that is provided: a) 9% per year with capitalization annually, b) 6.8% per year with capitalization semi-annually, c) 11% per year with capitalization monthly. 10. Determine the semi-annual effective interest rate,...
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a...
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a program in PERL with NO SUBROUTINES to allow the user to pick a type of arithmetic problem to study. An option of 1 means addition problems only, 2 means subtraction problems only, 3 means multiplication problems only, 4 means division problems only and 5 means random mixture of all these types. (Computer- Assisted Instruction) The use of computers in education is referred to as...
Write a Matlab script that computes the element level stiffness matrix and force vector for linear...
Write a Matlab script that computes the element level stiffness matrix and force vector for linear elasticity.
Write a simple PHP script. In your script use all of the following: HTML, Javascript, and...
Write a simple PHP script. In your script use all of the following: HTML, Javascript, and PHP.
Question: How does compound interest differ from simple interest?
  Question: How does compound interest differ from simple interest?
1. Write a simple batch include IFELSE statments? 2. Write a simple Powershell Script with IFELSE...
1. Write a simple batch include IFELSE statments? 2. Write a simple Powershell Script with IFELSE statements? 3. Explain this powershell script and write its output? $x = 30 if($x -eq 10){ write-host("Value of X is 10") } elseif($x -eq 20){ write-host("Value of X is 20") } elseif($x -eq 30){ write-host("Value of X is 30") } else { write-host("This is else statement") }
Simple Interest versus Compound Interest First City Bank pays 10% simple interest on its savings account...
Simple Interest versus Compound Interest First City Bank pays 10% simple interest on its savings account balances; whereas, Second City Bank pays 10% interest compounded annually. If you made $6,000 deposit in each bank, how much more money would you earn from your Second City Bank account at the end of 10 years; and, what is the amount for First City Bank? What is the simple interest amount for First City Bank; What is the amount of compound interest for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT