As a financial advisor, you are helping a young engineer,

Rosie. In order to take advantage of the tax exempt growth of Roth IRA.

Rosie wishes to compare the growth of two different contribution

options, A and B, after 40 years:

Option A. Rosie contributes $800 every month.

Option B. Rosie contributes $500 per month in the first year, then

increases her contribution by 10% every year. For example,

she will contribute $550 per month in the second year, and

$605 per month in the third year, and so on.

Each contribution is made at the beginning of month.

Assuming that her account grows monthly at an annual rate of 7.5%, you

are asked to compute and print Rosie's Roth IRA account balance,

the total contributions, and the tax exempt growth

(= balance - contributions) after 40 years for both options A and B.

I already did option A, the code is as follows. However, I am stuck on how to do part B. I did part of it but it doesn't come out right.

Code:

int months, years = 40, k;
double m_payment = 800.0, temp, bal, i_rate, t_payments, n_payment, bal_x;
printf("Option A\n");
i_rate = 0.075/12.0;
months = 12 * years;
t_payments = (double)months * m_payment;
temp = pow(1.0 + i_rate, (double)months);
bal = (temp - 1.0)/i_rate * m_payment;
printf("Rosie's Roth IRA\n");
printf("account balance = $%.2f\n", bal);
printf("total contribution = $%.2f\n", t_payments);
printf("tax exempt growth = $%.2f\n", bal-t_payments);
printf("\nOption B\n");
n_payment = 500.0;
for (k=0; k<years; k++) {
temp = pow(1.0 + i_rate, (double)months);
bal_x = (temp - 1.0)/i_rate * n_payment;
n_payment += 500.0 * .10;
printf("%.2f\n", n_payment);
printf("%.2f\n", bal_x);
}