repetition and selection- can anyone help?

This is a discussion on repetition and selection- can anyone help? within the C++ Programming forums, part of the General Programming Boards category; Hey all, I'm having a bit of trouble (ie. tearing my hair out in frustration) with repetition and selection. I ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    12

    Unhappy repetition and selection- can anyone help?

    Hey all,

    I'm having a bit of trouble (ie. tearing my hair out in frustration) with repetition and selection.

    I have to design a program that allows the user to input the amount of money invested into a savings account, the annual percent interest earned, and the length (in years) of the investment, and then calls a function to calculate and display a table of the monthly balances for the account that compounds interest quarterly (ie every three months).

    My main problems are, I can't figure out how to display years as months in a table. Eg. if the user entered 0.5 years, how would I get that to display in the table as

    -------
    length
    -------
    1
    2
    3
    4
    5
    6

    ???

    The other problem is that I have no idea how to make it calculate interest on the months it should- ie how do I get it to calculate the interest on the 3rd month, the 6th month, but not the others?

    Any help would be infinitely appreciated!

    Tarls.

  2. #2
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    float lengthInterest = 0.5 * 12;


    if (monthNumber % 3)
    {
    doInterest();
    }

  3. #3
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    Some math help:

    remember when you do calc the interest it needs to be divided by the quarters

    9% annual interest paid in quarters is:

    .09 /4 = .0225 each quarter. // The math always gets me

    *remember to add a 1 to your result, so it would be 1.0225 times your money amount.*
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21