You will be using a file that contains stock transactions of the type found in transactions. Each line of the file contains a transaction type, a stock symbol, the number of shares bought or sold, the price per share, the date of the transaction in month, day, year format, and the name of the individual. The name of the individual can consist of an arbitrary number of words. A multi-word last name is denoted with braces (<>).
Write an include file, transactions.h, that contains a typedef declaration for a struct that will contain the information for a single transaction. Use this include file for all of your programs. Since the struct you declare must include information for more than one program it will be bigger than if you targeted the struct for just one program. Do not worry about that.
Write a program called avg.c that prints the total cost of each transaction and then prints the average cost of all the transactions. Read the input from stdin. Each transaction should have its own line of output and each line of output should list the stock symbol, the quantity, the amount, and the total transaction cost. The total transaction cost should be rounded to two decimal places and should have the format xxxxxx.xx. In other words the total transaction cost should occupy a minimum of 9 character spaces. The format of a line should be:
xxxx xxxx xxx.xx xxxxxx.xx
The x's denote the minimum number of characters that each field should contain. The stock symbols should be left-justified and the remaining fields should be right-justified. The final line should have a blank line between it and the preceding transactions and should have the format:
average transaction cost = $xxxxxx.xxYour program may use a counter to count the number of transactions.
Write a program named name.c that prints each name in the file on a separate line using the format:
lastname, firstnameThe firstname may include a middle name or initial. No name should be printed more than once. You should maintain a dlist to keep track of the names your program has printed thus far. Read the input from stdin.
Write a program named sort_date that sorts the transactions in ascending order according to the date of the transaction. Earlier years should precede later years. The transactions should be printed out in the same format in which they were read. You should use a dlist to keep track of the transactions and should insert transactions into this dlist based on the transaction's date. The user should provide the filename as a command line argument. You should print out an error message if the user fails to provide a command line argument.
Write a program that sorts the transactions in alphabetical order by stock name. For each stock you should first print a line that contains the stock's name and the average transaction cost for that stock. The line number is the line that the transaction occurred upon in the original input file. You should then print the transactions for that stock using the following format:
line_number mm/dd/yyyy quantity price name
The precise format for your output should be:
xxxx average transaction = $xxxxxx.xx
xx xx/xx/xxxx xxxx xxx.xx xxxxxxxxxxxxxxxxxxxx
xx xx/xx/xxxx xxxx xxx.xx xxxxxxxxxxxxxxxxxxxx
....
xxxx average transaction = $xxxxxx.xx
xx xx/xx/xxxx xxxx xxx.xx xxxxxxxxxxxxxxxxxxxx
xx xx/xx/xxxx xxxx xxx.xx xxxxxxxxxxxxxxxxxxxx
....
There should be a blank line between each set of stock transactions.
You must use a doubly linked list to hold the stocks and each stock must hold a doubly linked list containing its transactions. You will lose points if you use only one doubly linked list.
The user should provide the filename as a command line argument. You should print out an error message if the user fails to provide a command line argument.
-I/home/parker/courses/cs302/includewhen you compile your .c programs into .o files. Then when you do the final linking to make an executable, make sure you link with
/home/parker/courses/cs302/objs/libfdr.a
You should submit the following files: