6.00:
Introduction to Computer Science and
Programming
Problem Set 4
Handed out:
Tuesday, September 24, 2008.
Due: 11:59pm, Tuesday, September 30, 2008
.
Introduction
This problem set will introduce you to using successive approximation, as well as data
structures such as tuples and lists.
Collaboration
You may work with other students. However, each student should write up and hand in his or
her assignment separately.
Be sure to indicate with whom you have worked.
For further detail,
please review the collaboration policy as stated in the syllabus.
Submission
This problem set, and future ones, will be auto-graded by a test harness. The test harness will
expect your files to include just function definitions, with no executable code outside the
function definitions.
All your testing code should be in the appropriate test function,
which is provided in the template; for example, the testing code for the futureRetire() problem
should be in testFutureRetire().
Be sure to add test cases to these test functions beyond what
is provided in the template!
Planning for the future
Recent events in the stock market may seem remote to you, but they underscore the
uncertainty of planning for the future.
People who had been thinking of retiring in the next year
or so may have to rethink those plans, as the value of their 401K accounts drops noticeably.
Although retirement may seem a long way off for you, we are going to explore some simple
ideas in accruing funds.
Along the way, we are going to explore the use of successive
approximation methods, as well as the use of some simple data structures, like lists.
We are going to start with a simple model of saving for retirement.
Many employers will
contribute the equivalent of 5% of your salary to a retirement fund, and then will match any
contribution that you add, dollar for dollar, up to an additional 5%.
Thus you can salt away up
to 15% of your salary into a retirement account (10% of which comes as a bonus from your
employer).
We can model a retirement fund with some simple equations.
Assume your starting salary is
represented by salary; that the percentage of your salary you put into a retirement fund is
; and that the annual growth percentage of the retirement fund is growthRate.
Then your
retirement fund, represented by the list F, should increase as follows:
save