Practice

RRSP

Design and code a class named RRSP that holds information for a Registered Retirement Savings Plan account and tracks the current balance in the account.

Upon instantiation, an RRSP object may receive a null-terminated C-style string holding a description of the plan, a floating-point value holding the amount of the initial deposit and a floating-point value holding the annual interest rate.  If no information is provided, the object assumes a safe empty state.  Do not assume that the description is limited to any number of characters.

• const char* description() const - a query that returns the description of the plan;
• double balance() const - a query that returns the current balance in the account;
• double accrued() const - a query that returns the interest accrued to the account;
• void accrueInterest(int days) - a modifier that calculates the interest on the current principal at the current annual rate and adds that interest to the accrued amount for the account; and
• void compound() - a modifier that compounds the accrued interest with the current principal.
Your design also includes an insertion operator that inserts into an ostream the following information on a single line:
• the current balance in a field of 10 with 2 decimal points;
• the current rate in a field of 5 with 2 decimal points;
• the accrued interest in a field of 8 with 2 decimal points; and
• the description of the plan preceded by a single blank character.
Design your operator so that it handles cascading.  See the example shown below.

Include all of the functions necessary to ensure the proper copying and assignment of the data from one object to another and to avoid memory leaks.

For example, the following program uses your class and produces the output shown on the right

 ``` #include using namespace std; #include "RRSP.h" int main ( ) { RRSP a = b("3 Year Term", 1000.00, 0.03); cout << a.name(); << a.balance(); << a.accrued(); a.accrueInterest(365); a.compound(); b = a; a.accrueInterest(100); cout << a << endl; cout << b << endl; return 0; } ``` ``` 3 Year Term 1000.00 0.00 1030.00 0.03 8.47 3 Year Term 1030.00 0.03 0.00 3 Year Term ```

 Designed by Chris Szalwinski Copying From This Site