CS302 -- Lab 4-- Stock Reports


Lab Objective

This lab will accomplish a number of objectives:

  1. It will give you experience writing classes
  2. It will expand your knowledge of C's IO system
  3. It will help you review your knowledge of hash tables
  4. It will give you more experience using doubly linked lists and balanced binary trees
  5. It will give you experience using C++'s reference type
  6. It will give you experience with overloading operators and constructors
  7. It will give you experience using template classes


Problem Statement

Your program is going to read a file (e.g., transactions) of stock transactions and organize the transactions by person. For each person you are going to sort the transactions alphabetically by stock symbol and for each stock symbol you are going to sort the transactions into ascending order by date. You will use a hash table to search for people, a red-black tree for each person to sort each person's stocks into alphabetical order, and a red-black for each stock to sort the transactions into ascending order based on date. The hash table will use separate-chaining and you will use doubly-linked lists to handle the lists for each hash table entry.

Once you have read all the data from the transactions file you will allow the user to enter the last names of individuals. You will then print out all of the stocks for that individual in alphabetical order and for each stock you will print the transactions for that stock in ascending order by date. You will repeatedly query the user for lastnames until the user hits Ctrl-D, thus ending the program.

A binary executable (called SortStock) has been provided for you so that you can see what your program should do on a given input file. To access it you should copy over the transactions file to your directory and type:

/home/parker/courses/cs302/labs/lab4/SortStock transactions


Format of the Input File

The input file is going to consist of lines that have no blank spaces. Your program will identify the fields in a line according to the following format: