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)

Copy Code

P = A * I + 2 * P;

C#

Copy Code

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.

C#

Copy Code

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)

Abhishek Pant2-Nov-14 3:03am`CASE [ expression ]`

WHEN condition_1 THEN result_1

WHEN condition_2 THEN result_2

...

WHEN condition_n THEN result_n

ELSE result

END

just like you do in c#