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 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...
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...
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,...
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.
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") }
Python programming c++ Write a program that computes the amount of money the cheerleaders raised during...
Python programming c++ Write a program that computes the amount of money the cheerleaders raised during their candy bar fundraiser using the following data: 12 bars per case. The candy was sold for $1.00 per bar. Each case cost $8.00. They are required to give the student government association 10% of their earnings. The program should ask the user how many bars were sold. The program should calculate and display the SGA proceed's, the Cheer team's proceeds, and the appropriate...
Question: How does compound interest differ from simple interest?
  Question: How does compound interest differ from simple interest?
Linux Script Convert String (Part 1) Write a simple shell script that takes a permission string...
Linux Script Convert String (Part 1) Write a simple shell script that takes a permission string expressed as -rwxrwxrwx and prints out whether or not theobject is a directory, file or link. The string is read in from standard input. Convert String (Part 2) Modify the script so its able to print out the octal permission which the string represents along with the file type. This is in addition to part 1. Convert String (Part 3) For the script in...
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...
1. Simple Interest versus Compound Interest First Tappan Bank pays 9 percent simple interest on its...
1. Simple Interest versus Compound Interest First Tappan Bank pays 9 percent simple interest on its savings account balances, whereas First Mullineaux Bank pays 9 percent interest compounded annually. If you made a $7,500 deposit in each bank, how much more money would you earn from your First Mullineaux Bank account at the end of 8 years? 2. Calculating Future Values For each of the following, compute the future value: Present Value Years Interest Rate Future Value $2,328 11 13%...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT