## Homework #4: Stock Market Simulator

Due: November 11, 1998

Now that we understand the fundamentals for C, we can start creating some more interesting programs. For Homework #4, you are to build a very simple Stock market simulator that tracks one week's worth of stock data for a single company. Here's how it will work:

• Your program should store 5 day's worth of stock data within a single array. The array should only hold integer values (don't worry about floats.)
• When the program first runs, you should initialize the stock array with random values. For our simulator, stock prices can vary from \$1 to \$32.
• Once you have initialized the array, the user has four options:
1. Print the stock prices (sample output provided below.)
2. Graph the stock prices (sample output also provided below.)
3. Generate new random stock values, or
4. Exit the program
Important Notes:
• To graph the stock prices, use a very simply bar chart of * characters. The bar chart should display one * for each dollar, and should be plotted horizontally (plotting this vertically is possible, but we haven't really covered how to do this.)
• You should provide error checking on user input. For example, if the user enters 6, the program should indicate that this is invalid.

To get full credit for this program, you must create three functions:

• First, you must create a function called initStocks() that initializes the stock array with random number values.
• Second, you must create a function called printStocks() that prints each element in the array, and
• Third, you must create a function called graphStocks() that graphs each element in the array.

Here is some sample output:

```Welcome to the Stock Market Simulator.
Generating Random Stock values...
1)  Print Stock Values
2)  Graph Stock Values
3)  Get new Random Stock values
4)  End Program
Day #0:  5
Day #1:  9
Day #2:  22
Day #3:  22
Day #4:  32
Day #0: 5 -->   *****
Day #1: 9 -->   *********
Day #2: 22 -->  **********************
Day #3: 22 -->  **********************
Day #4: 32 -->  ********************************
Generating Random Stock values...
1)  Print Stock Values
2)  Graph Stock Values
3)  Get new Random Stock values
4)  End Program
Day #0:  15
Day #1:  23
Day #2:  15
Day #3:  16
Day #4:  18