Lab 11
Implement a class that models an investment. Your class should have the following:
- a default constructor that sets the present value to $1, the nominal
rate to 0%, the compounding frequency to 1 period per year, and the term to
1 year.
- an initialization constructor that sets the present value, the nominal
rate, the periods per year, and the term to the specified values.
- a copy constructor that creates a new investment with the same state as
the specified investment.
- a function (setPV) to set the present value.
- a function (setRate) to set the nominal annual rate.
- a function (setFreq) to set the compounding frequency.
- a function (setYears) to set the term.
- a function (getPV) that returns the present value.
- a function (getRate) that returns the nominal annual rate.
- a function (getFreq) that returns the compounding frequency.
- a function (getYears) that returns the term.
- a function (getFV) that returns the future value.
- a function (getInterest) that returns the total interest earned.
- a function (getAPY) that returns the annual percentage yield.
One of the advantages of a class is that you can guarantee that the state of
an object is always valid. A valid investment has a positive present value, a
non-negative nominal rate, a compounding frequency of 1, 2, 4, or 12, and a
positive term. I've provided skeleton code for the class methods and a test program in the file
Lab11.cpp. All you need to do is implement each class
method.