I have an assignment in which I need to calculate annual interest.
IE:
P1 = P0 + P0*INT (interest) = P0*(1+INT)
P2 = P1 + P1*INT = P1*(1+INT) = P0 * (1+INT) * (1+INT) = P0 * (1+INT)^2
P3 = P2 + P2*INT = P2 *(1+INT) = P0 * (I+INT)^3
And so on.
essentially, here is what I have so far.
\*Notes
The initial statement is supposed start at 1700, it's supposed to compound for 60 years, and it has to be a 10% interest rate.
*\
Expand|Select|Wrap|Line Numbers
- # include <iostream>
- # include <iomanip>
- using namespace std;
- int main (int argc, char* argv[])
- {
- int i; // counter
- double Initialstatement = 1700;
- int Numberofyear = 60;
- double Interest = 0.1;
- double Totalamountyr;
- double TotalamountFinal;
- for (i = 0; i < Numberofyear; i++)
- {
- Initialstatement = Initialstatement * Interest + Initialstatement;
- TotalamountFinal = Initialstatement + (Initialstatement * Numberofyear);
- }
- cout << fixed << showpoint;
- cout << setprecision(2);
- cout << TotalamountFinal << "\n";
- system ("PAUSE");
- return 0;
- }
Instead of acquiring interest from the previous year each year and adding it, it goes off in the wrong direction the minute i = 1 (or more than 1 year for the # of years)
So, how can I set this up using loops, and not using powers?
My professor won't let me use power functions.