### Interest coding program?

I was giving the task to make a program with these instructions: Use cmath with the pow function to find the amount when \$ 1000 is deposited at 2% compounded quarterly, for 2 years, 5 years, and 10 years. The equation I was also given was:
A=P(〖1+ r/n)〗^nt

P = Principal the amount you initially deposit.
r = interest rate as a decimal
n = number of compounding periods per year (example quarterly n = 4, monthly n = 12)
t = number of years.
A = amount you have at end of t years.

I am lost on where to begin. I never made a program with cmath or anything.
 ``123456`` ``````#include int main() { // YOUR CODE GOES HERE }``````

cmath provides you with some functions: http://www.cplusplus.com/reference/cmath/
Last edited on
Do I have to add #include<iostream> first? then the #include<cmath>? I am still not sure on how to put that whole thing into a code. I don't know how to do loops or anything.
The #include<iostream> is a preprocessor order, that allows for output/input from the console. If you are not going to use any couts, which I really doubt, then dont use, otherwise is not too bad to include it always at the beginning of your code.
A is what you're calculating - I'd think you'd want to output each of the three results to the screen with cout?

You're given values for P, r, n and t in the problem - you just need to make the code do the math of the formula, running it three times for the different values of t (2, 5, 10).
Topic archived. No new replies allowed.