Assg 02: Classes COSC 2336 Data Structures Objectives • Create a simple class • Practice using math functions • Practice with C++ string types and I/O streams • Use a class constructor • Example of test driven development Description Typically, most everyone saves money periodically for retirement. In this exercise, for simplicity, we assume that the money is put into an account that pays a ?xed interest rate, and money is deposited into the account at the end of the speci?ed period. Suppose the person saving for retirement depositsD dollarsmtimesperyear. Theaccountpaysr%compoundinterest rate. And the 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. And the person as t = 25 years to save for retirement. The total amount of savings S accumulated at the end of this time is given by the formula S = Dh(1 + r/m)mt ?1 r/m i For example, suppose that you deposit $500 at the end of each month (m = 12). The account pays 4.8% interest per year compounded monthly for t = 25 years. Then the total money accumulated into this account is 1 500[(1 + 0.048/12)300 ?1]/(0.048/12) = 289,022.42 . On the other hand, suppose that you want to accumulate S dollars in savings, and would like to know how much money you should deposit D each deposit period. The periodic payment you need to reach 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 calculate retirement savings and to help plan retirement goals. Your class should have private instance variables (all of type double) to hold D the deposit amount, m the number of deposit periods per year, r the interest rate and t the time in years the plan will save for retirement. In the class style guidelines, I discourage using single letter variable names usually when writing code. However when we are directly implementing a formula in an engineering or scienti?c calculation, it is often clearer to use the variable names 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 have a class constructor that takes the 4 variables, D, m, r, t as parameters. 2. Create a default class constructor as well. This constructor can set all of the private member variable values to 1.0. 3. You must have getter and setter methods for all 4 of the member 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 will not take any parameters as input. It returns a string that represents the values/settings of the RetirementAccount class. See the example output below for the format of the string to be returned. 5. Create a member function named calculateRetirementSavings(). This function should implement the ?rst formula to calculate the total amount of savings S the account will generate. This function has no parameters as inputs, and it returns a double amount (the amount of savings) as its result. 2 6. Create a member function named planRetirementDeposits(). This function takes a double parameters S as input, which is the savings goal you wish to achieve. This function should implement the second equation given above. The function returns a double result, D which is the amount of money that should be deposited each period to meet the savings goal S. As before you will be given a starting template for this assignment. The template contains all of the tests your class and member functions should pass for this assignment. You should write your program by uncommenting the tests/code in main 1 at a time, and writing your class incrementally to work with the test. If you perform all of the above tasks correctly, the tests given to you in the starting template will produce the fol…

Looking for solution of this Assignment?

WHY CHOOSE US?

We deliver quality original papers

Our experts write quality original papers using academic databases.We dont use AI in our work. We refund your money if AI is detected  

Free revisions

We offer our clients multiple free revisions just to ensure you get what you want.

Discounted prices

All our prices are discounted which makes it affordable to you. Use code FIRST15 to get your discount

100% originality

We deliver papers that are written from scratch to deliver 100% originality. Our papers are free from plagiarism and NO similarity.We have ZERO TOLERANCE TO USE OF AI

On-time delivery

We will deliver your paper on time even on short notice or  short deadline, overnight essay or even an urgent essay