The following formula will compute the Total Amount


The following formula will compute the Total Amount that will be accumulated for a given
Monthly Amount saved:

Notice that his formula also requires that you first calculate a factor and then use it in your
formula. The factor formula is:

factor = exp( numberOfMonths * log(1 + monthlyInterestRate))

exp and log are predefined mathematical functions, located in the C++ library.

For hand calculating results to test your program, the equivalent algebraic equation is:

factor = (1 + monthlyInterestRate) numberOfMonths

Write a program to output accumulated values for each month, given a set amount saved each
month, until the accumulated amount reaches a set goal amount.

Discussion about comparing floating point values:

Given two floating point values:

num = 9.99999999

num2 = 10.00000000

If both are displayed to two decimal places, you will see:

10.00 and 10.00

However, if you compare the same two values within your code, to see…

View original post 695 mots de plus

Par défaut