I am creating a financial consule application to calculate deposits each month for 40 years at 0.07 interest. The amount deposited per month is $300.00 for a total of 480 months. I need to calculate that total, then take an annual payment of $91800 per year for 30 years from the total calculation. With each annual withdrawal I want to calculate the new balance at .085 percent interest until the end of the 30 year period. The problem I am having is that my code seems to show the inital calculation in exponent form, also when I take the annual payment it adds instead of subtracting from the balance.
The code for the first 40 years is below:
double p(0), fvr(0.07), r(.085), fv(0), Pi(0), dep(300), pmt(91800);
int n(480), i(0), e(0), y(30);
while( i != n ) // iterate n times
{
fv = fv * ( 1 + fvr ) + dep;
++i ; //increment to next period
}
//----- Code for the remaining 30 years-----
while( e != y ) // iterate n times
{
Pi = Pi * (1 + r ) - pmt;
++e ; //increment to next period
}
--------------------------------
Thanks in advance.
aj85
You probably want to divide it by 12 to get monthly factor!
Probably why your money grew so fast!