Thread: compounding interest/ Roth IRA calculation help

  1. #1
    Registered User
    Join Date
    Nov 2010

    compounding interest/ Roth IRA calculation help

    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.

    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);
    Last edited by Salem; 12-01-2010 at 10:44 PM. Reason: Added code tags

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > n_payment += 500.0 * .10;
    1. You need 2 loops, for years and months. The payment per month increases once per year.

    And this isn't adding 10%
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2010
    I tried to plan out my coding, but I just can't picture how I will be able to do option B

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please do my bank interest calculation homework
    By kufur in forum C Programming
    Replies: 3
    Last Post: 12-30-2009, 12:17 PM
  2. Programming project help?
    By Debbie Bremer in forum C++ Programming
    Replies: 21
    Last Post: 10-11-2008, 02:48 AM
  3. Compound Interest Formula
    By veronicak5678 in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2007, 05:16 PM
  4. Loan calculation formula
    By C++Nerd in forum C++ Programming
    Replies: 1
    Last Post: 10-06-2002, 12:57 PM
  5. compounding interest
    By devinm in forum C++ Programming
    Replies: 2
    Last Post: 11-08-2001, 08:43 AM