Lab 4

Write a Java class named "Investment" that models a one-time investment that earns compound interest. Your class should have four instance variables:

  1. double pv; the present value (the amount that was invested)
  2. double r; the nominal interest rate (in decimal form)
  3. int t; the time in years
  4. int ppy; the number of periods per year (the compounding frequency)

Your class should include the following methods

Notice that the first four getters simply return the values of the corresponding instance variables. The last two getters, must perform a calculation in order to determine the value that will be returned.

Your class file should include appropriate documentation comments for the class as a whole and for each method. The Java class implementation is worth 10 points and appropriate documentation comments are worth an additional 5 points.

Investment Formulas

Here are the formulas for the future value (fv) and the interest earned (I):

fv = (1 + r/ppy) ^ (t*ppy), I = fv - pv

Submitting Your Work

Send me your "Investment.java" file as an attachment to an email message whose subject is "Lab04".