Description
Typically, most everyone saves money periodically forretirement. In this exercise, for simplicity, we assume that themoney is put into an account that pays a fixed interest rate, andmoney is deposited into the account at the end of the specifiedperiod. Suppose the person saving for retirement deposits D dollarsm times per year. The account pays r% compound interest rate. Andthe person will be saving for a period of t time given in years.For example, the person might save D = $500 every m = 12 months.The retirement account pays 4.8% compound interest per year. Andthe person as t = 25 years to save for retirement. The total amountof savings S accumulated at the end of this time is given by theformula
S = D h (1 + r/m) mt − 1 r/m i
For example, suppose that you deposit $500 at the end of eachmonth (m = 12). The account pays 4.8% interest per year compoundedmonthly for t = 25 years. Then the total money accumulated intothis account is
500[(1 + 0.048/12)300 − 1]/(0.048/12) = 289, 022.42
On the other hand, suppose that you want to accumulate S dollarsin savings, and would like to know how much money you shoulddeposit D each deposit period. The periodic payment you need toreach this goal S is given by the formula
D = S(r/m) (1 + r/m)mt − 1
Design a class that uses the above formulas to calculateretirement savings and to help plan retirement goals. Your classshould have private instance variables (all of type double) to holdD the deposit amount, m the number of deposit periods per year, rthe interest rate and t the time in years the plan will save forretirement. In the class style guidelines, I discourage usingsingle letter variable names usually when writing code. Howeverwhen we are directly implementing a formula in an engineering orscientific calculation, it is often clearer to use the variablenames directly as given in the formula.
For this assignment you need to perform the following tasks.
1. Create a class named RetirementAccount. The class should havea class constructor that takes the 4 variables, D, m, r, t asparameters.
2. Create a default class constructor as well. This constructorcan set all of the private member variable values to 1.0.
3. You must have getter and setter methods for all 4 of themember variables of the class. The methods will be named set_D(),set_m(), set_r(), set_t() and get_D(), get_m(), get_r(), get_t(),respectively.
4. Create a member function named tostring(). This function willnot take any parameters as input. It returns a string thatrepresents the values/settings of the RetirementAccount class. Seethe example output below for the format of the string to bereturned.
5. Create a member function named calculateRetirementSavings().This function should implement the first formula to calculate thetotal amount of savings S the account will generate. This functionhas no parameters as inputs, and it returns a double amount (theamount of savings) as its result.
6. Create a member function named planRetirementDeposits(). Thisfunction takes a double parameters S as input, which is the savingsgoal you wish to achieve. This function should implement the secondequation given above. The function returns a double result, D whichis the amount of money that should be deposited each period to meetthe savings goal S.
Itsin C++ language.