Exercise: Interest Calculator

For this exercise, you're going to perform a compound interest calculation. This program will calculate the interest on a savings account, given some information about interest rates, deposits, and time. The formula you're going to use is as follows:

Using your text editor, type the program from Listing 2.2 and save it as Interest. Do not type in the line numbers. Make the program executable according to the instructions you learned in Hour 1.

When you're done, try running the program by typing the following at a command line:

perl Interest

Listing 2.3 shows a sample of the Interest program's output.

Listing 2.2 ...

Get Sams Teach Yourself Perl in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.