Assume you wish to deposit a particular amount of money into the saving account, and then leave it alone in order to draw the interest for next 10 years. At the end of 10 years you would like to have $10,000 in the account. How much do you require to deposit today in order to make that happen? You may utilize the following formula that is known as the present value formula, to determine:
P= F/(1/+r)^n,
Where:
P is the present value, or amount that you require to deposit today. F is the future value which you want in account. (In this case, F is $10,000), r is the annual interest rate (expressed in the decimal form), n refers to the number of years which you plan to let the money sit in the account.
Write down a program that has a function named presentValue which carry out this calculation. The function must accept the future value, annual interest rate, and number of years as arguments. It must return the present value, which is the amount that you required to deposit today. Demonstrate the function in the program that lets user experiment with several values for the formula’s terms.