CIS 15BG Assignment 5
Array of structures
If you wish, you may do problems 5 and 6 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 on each problem, 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.
NOTE that the company names are different than in lab 2, but the prices are the same.
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 Fracting and Pumping 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 Container Shipping 93.21 93.11 93.02 93.31 92.98 92.89 Gold Bugs
Type this data, exactly as shown, into a file, or copy your data from lab 2 and change the company names.
There will be ONE array of companies. Each company data will be kept in a structure. The structure will contain: - A pointer to heap space containing the company name - An array of 6 hourly prices - The average price for the day These structures shall be kept in an array of 20 structures.
Read the data from the file, and put the data from each line into the next structure in the array of structures.
For each company compute and print the average of all of the six prices for that company. Store the average in the structure.
Sort the array of structures alphabetically, by company name.
Print all the data from each company structure in a nice format.
Use the hours in the heading for each column of
hourly price data.
Do NOT print the unused entries at the end of the array.
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.
You might wish to print all the reaults in one output table.
Organize your program into several compact functions. There should be very little code in main.