Compound Interest Help Please!!

I am working on a program that uses a 2% monthly compounded interest on an initial investment with a monthly deposit, output how many months it will take to reach a certain goal using a recursive function
I am not getting the monthly total to output

Here is my code
int bank(double, double, int); // We are looking for 3 things so we are going to send 3 things

int _tmain(int argc, _TCHAR* argv[])
{

double investment = 0;
double monthly = 0;
int month = 0;

cout << "Please enter your investment : ";
cin >> investment; // user enters investment
cout << "What is your monthly investment : ";
cin >> monthly; // user enter their monthly deposit

month = bank(investment, monthly, month); // calling function

cout << "It will take you " << month << " months to reach at least 500,000";

return 0;
} // end of main


//bank recursive function
int bank(double compound, double monthlyfunds, int addmonth)
{
//cout << compound << "\n";
if (compound >= 500000) // tests whether the investment has reached 500,000
{
return addmonth +1; // adds 1 each time it isnt 500,000
}
else
{
return bank(((compound + monthlyfunds) * 0.02), monthlyfunds, (addmonth + 1)); // recurisve statment: keeps adding up the investments and monthly funds and months while its under 500,000
}
} // end of function
Last edited on
Your calculation of the new amount of money in the account after applying the monthly interest is incorrect.
How do I fix it?
The amount of money in the account after interest is applied is:

( amount of money in before the interest is applied ) + ( the interest )
Topic archived. No new replies allowed.