CSci 150: Foundations of computer science I
Home Syllabus Assignments Tests

Assignment 4: Traditional IRAs

Due: 2:00pm, Monday, September 21. Value: 30 pts. Submit to Sauron.

The U S government provides several tax incentives to encourage middle-income individuals to invest toward their retirement. One mechanism is called the Traditional IRA. This allows a taxpayer to create an IRA account, frequently in a mutual fund working in the stock market. Then each year, the taxpayer can invest up to $5,000 of income in the IRA account, and that invested income is then exempt from income taxes. Also, any interest or capital gains in the account are tax-exempt. Tax is not avoided completely, though: Income tax must eventually be paid when money is later removed from the account, usually during retirement. Overall, though, you come out well ahead of doing your investing outside an IRA.

Your assignment is to write a program that estimates how much money you can receive in retirement based on your IRA account if you make regular annual investments. Your program will read four inputs from the user.

Age at which you start investing
Amount invested each year
Estimated interest rate
Age at which you plan to retire

It should then display how much will be in your account after each year, followed by the amount of interest received in the year when you retire (which is roughly how much you would be able to withdraw annually thereafter). An example of a run of the program is as follows, with user input in boldface.

Starting age? 20          (Feel free to improve on this user interface.)
Annual deposit? 4000.00
Interest rate? 4.0
Retiring age? 64
20: 4000.0
21: 8160.0                (This is 4000 * 1.04 + 4000.)
22: 12486.4               (This is 8160 * 1.04 + 4000.)
23: 16985.856
 :                        Lines omitted. Another page has the complete output
63: 461651.507832827
64: 484117.5681461401
After retirement, you can withdraw $19364.702725845604 each year.
            $19,364.70 is 4% of the age-64 balance, since the interest rate is 4%.

If you run it with the same parameters, except that you wait until 30 to start investing, then you'd only be able to withdraw $11,784.36 each year.

Because this program involves no graphics, you'll find it convenient to have extends Program in place of extends GraphicsProgram at the top of your program. This way, the graphics window won't appear when the program starts.

[Because of the effects of interest, many financial advisors suggest that people start early investing in the stock market toward retirement, either while in college or immediately thereafter. Two reasonable sources of financial advice are the federal government and a mainstream financial radio program.]

[Incidentally, the 4% interest rate is fairly realistic. From 1950 to 2008, the S&P 500 averaged a 3.76% return in real terms (i.e., after factoring inflation out).]