Question: C++ Programming Question. In part 2 you will be creating multiple functions to calculate the present value You may be asking what a present value
C++ Programming Question.



In part 2 you will be creating multiple functions to calculate the present value You may be asking what a present value" is. Suppose you want to deposit a certain amount of money into a savings account and then leave it alone to draw interest for some amount of time, say 12 years. At the end of the 12 years you want to have $15,000 in the account The present value is the amount of money you would have to deposit today to have $15,000 in 12 years The formula used needs the future value (F) and annual interest rate (r) and the number of years (n) the money will sit in the account, unchanged. You will be calculating the present value (P) Note: Older browsers may have issues displaying the above formula properly. In the above expression the value (1 +r) needs to be raised to the nth power. Assume that A is the power function and xA2 is x to the 2nd power (x squared) we can rewrite the above expression as P F/((1+r)A n) You are not allowed to use any global variables. Use of global variables will result in a grade of zero for part 2. You must have functions to read in the future value, the annual interest rate, and the number of years. That would be three different functions. Give these functions meaningful names. Note that the order of the values will be future value, annual interest rate, and number of years In all cases you need to return any valid value back to the calling function. For all three functions you will write out to cout as prompt for an input value. You will read in that value from cin. If the value is invalid (zero or negative) you need to display an error message and reread the value (with another prompt). You need to do this in a loop and continue looping until a valid value has been entered. Only the number of years can be an int value. The rest should be of type double Here are the prompts for the three values you need to read in: Enter future value Enter annual interest rate Enter number of years Note that the interest rate will be a number such as 10 or 12.5. These are to be read in as percentages (10% and 12.5%). You will need to divide these values by 100 to convert them into the values needed in the function (.1 and.125 for the above values). This conversion needs to be done before you call the calculatePresentValue function (see below) Here are the error messages you need to display if the values are negative The future value must be greater than zero The annual interest rate must be greater than zero The number of years must be greater than zero You will also need a function called calculatePresentValue with the following signature double calculatePresentValue (double futureValue, double interestRate, int numberYears)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
