Computer Science I for non-majors by James Tam |
Due: Due Monday October 21 at 4 PM.
Introduction to investing1 |
|
|
Write a program that allows the user to invest in one of three investment products, each with a different level of risk. The goal is to reap maximum returns at the end of the year (and in the long term earn maximum returns for the 10 year simulation span). The starting cash is $100. To simplify things all cash must be invested wholly in a product for an entire year - no 'diversifying' or splitting amounts between multiple products is possible. To implement the random nature for each of the three products you can use the pre-created code in the 'random' library module.
Product I, Fly-By-Night Investments (Stock code: SCAMU): high risk, high potential returns
Product II, Blue Chips INC. (Stock code: BCI): moderate risk, good potential yearly returns
The losses/gains are average performance of an investment over a year.
3 To reduce the complexity when generating the probability of a gain or a loss the program only has to generate integer value percentages e.g., 1%, 2%, 3% etc. and not the real number values in between these integers. So when generating the chance of loss or gain for BCI then the program would just generate a value from 1 - 100%. In a similar fashion the range of percentages for the average increase or decrease of an investment during a year will also consist only of whole number percentages.
Product III, Slow-And-Steady Corp. (Stock code: BORE), mature industry stock: no risk but low returns
As mentioned losses or gains will be calculated yearly, year end monies carried over as the starting money for the next year.
When the simulation starts the user's investment portfolio starts at the default of $100, zero years have passed. The user will be shown a menu of investment products (as well as brief description of each).
If a selection doesn't match option 1 - 3, then the program will continue prompting the user until a value within this range has been entered.
At the end of each year the following financial report should display the year and current risk level (high, medium or low) on one line and on the line below it a summary of the performance for year:
Format: <Year/Time units passed> <Investment risk level> <Amount of money at the start of the year> <Dollars earned or lost during the year> <Amount of money at the end of the year> |
|
Example: |
The program will run for a ten years at which point it will display a summary for the tenth year as well as displaying performance spanning the entire ten year period.
Format: <Amount of money at the start of the simulation> <Dollars earned or lost during the 10 years <Amount of money at the end of the simulation> <Percentage return over 10 years, rounded to 1 fractional digit> <Average yearly percentage return, rounded to 1 fractional digit >4 |
|
Example (notice that THE FORMATTING
AT THE END OF TEN YEARS IS DIFFERENT from the yearly report in order to
make it stand out): |
They can be found under the A2 directory: /home/courses/217/assignments/assignment2
Among other things you can see the program output in one complete continuous run (giving you an idea of the above parts connect together).