I've got a project where I have to use a NESTED for loop to calculate how much interest occurs at x% rate over x amount of years for an initial investment of $1000. Trouble is, i dont understand how a for loop is going to do this for me. (keep in mind, im a newbie, my teacher is not very good and for loops are my weakest)
year 1 year 2 year 3 year 4 year 5
6%:
7%: THE ACTUAL ACCOUNT BALANCE DATA SHOULD APPEAR
8%: IN HERE NICELY FORMATTED
9%:
10%:
11%:
12%:
It's gotta appear in that format. Now, the formula (for the first one, accruing interest monthly) would be amt = (amt * (.06/12)) + amt. The outter loop would be something like (count = 0; count <= 7; count++)
inner loop for (count = 0; count <= 5; count++)
now where would i put the actual calculation of the interest and stuff? I tried this method with no avail (not to mention an infinite loop):
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
int main()
{
float intrate, amt;
int count;
intrate = .06/12;
amt = 1000;
for(count = 0; count <= 7; count++){
for(count = 0; count <= 5; count++)
amt = (amt * intrate) + amt;
}
cout << amt << endl;
system("pause");
return 0;
}