CIS 15BG Assignment 2

Parallel two dimensional arrays

If you wish, you may do this problem in a team of two. Clearly identify which student codes which of the parts. You should divide the work approximately evenly. Both will receive the same grade, so each student should carefully check the entire program.

The following data is the hourly price of each specified stock. The price is shown as of 10AM, 11AM, NOON, 1 PM, 2 PM, and 3 PM.

51.41  52.07  52.01  51.22  50.44  49.97  Coal Diggers
77.26  78.33  78.29  78.12  77.09  75.74  Airplane Flyers
31.25  31.44  31.43  31.09  31.01  30.92  Oil Pumpers
 2.03   2.02   2.04   2.00   1.98   1.97  Big Bank
44.21  44.32  44.29  43.98  43.82  43.71  Rail Shipping
93.21  93.11  93.02  93.31  92.98  92.89  Gold Bugs

Type this data, exactly as shown, into a file. There will be two parallel arrays. Put the prices in the first two dimensional array. Put the names in the second two dimensional array. These two arrays are parallel; each row in the first array corresponds to the same row in the second array. That means, for example, the third row in the price array will contain the prices for the company named in the third row in the name array.

Read the data from the file, and put it in these two two dimensional arrays.

It might be good to put the specified times in a third array. Rows in this array correspond to the columns in the price array. These times can be set up as internal constants, rather than reading them from the input.

Print all the data read in from the file in a nice format.

For each company compute and print the average of all of the six prices for that company. Print all these average company prices in a nice format.

For each hour compute and print the average of all the stock prices for that hour. Print all these average hourly prices in a nice format.

It might be good to print all the data in one table, rather than printing the three output requirements separately.

Organize your program into several compact functions. There should be very little code in main.