This is a pretty simple math operation.
Basically what you want is to loop through the number of months delay and calculate the sum of the interest for each month + the previous value doubled.
This formula should help you along in your school work.
(if it is not school work it is a bit scary)
P = A * I + 2 * P;
double P = 0.0;
int monthsDelayed = 4;
for (int i = 0; i < monthsDelayed; i++)
{
P = A * I + 2 * P;
}
Of course it can be done without the loop as well.
int monthsDelayed = 4;
double P = A * I * (Math.Pow(2, monthsDelayed) - 1);
(Haven't done much math in a long time so it took me a while to see the pattern)