CPSC 220 Fall 2007
Program 2: Ranking Employers
In Program 1 you processed employment data for the Roanoke area, aggregating
employers with multiple locations and allowing the user to search
for an employer by name. In this assignment you will extend that program
as described below
to allow the user to find the largest employers in the area.
Input and Output
Like Program 1, your program should prompt the user for the data
file and should allow the user to search for companies by name.
In addition,
it should allow the user the list the next N largest employers -- those
with the
most employees -- in order from highest to lowest. To determine how
many employees an employer has for these purposes, use the
aggregate number of employees from all of the employer's locations, and
take the average of these aggregates over the three months. For example,
Wal Mart's empoyment data is as shown below:
Address 1: 4807 VALLEY VIEW BLVD N.W. ROANOKE, VA 24012
Employees: 406,413,412
Address 2: 1851 W MAIN STREET SALEM, VA 24153
Employees: 355,351,335
Address 3: 313 WEST THACKER ROAD COVINGTON, VA 24426
Employees: 245,245,253
Address 4: 4210 FRANKLIN RD ROANOKE, VA 24014
Employees: 228,232,222
Address 5: 1455 TOWN SQUARE BLVD ROANOKE, VA 24012
Employees: 161,156,157
Total Employees: 1395,1397,1379
For purposes of this ranking, Wal Mart has (1395 + 1397 + 1379)/3 = 1390
employees (truncate fractional employees).
Give the user a menu so that they can switch back and forth between searching
for a company by name and listing the next N top employers. Note that
if the user asks for the next 10 top employers and then the next 10 top
employers again, they should get two different lists -- the first will have
employers #1-10, the second will have employers #11-20.
Program Structure
This program builds directly on Program 1 as follows:
- As in Program 1, start by reading the data and building
a binary search tree containing
all of the employers. Note that this stage also aggregates information
from any employer with multiple addresses.
- Now traverse the binary search tree in any order and insert each employer
into a priority queue. A few notes:
- Your heap priority queue classes from the lab/homework
should work for this without
modification, except that you will need to be sure they can hold enough data.
- You will have to make your Employer class Prioritizable, with a
priority() method that returns the average of the total number
of employees over the three given months.
- Of course, building the priority queue should not disturb your binary
search tree.
Documentation
Program documentation is very important. Follow the guidelines below:
- Use good variable and method names. This will make life easier for
you and for the reader.
- For each method include a header describing the parameters and the
return value, if any, and clearly indicating any change the method makes
to the object's state (memory, input, output).
- Identify important segments of code so that the reader can easily
follow the flow of the program without reading every line of code. For
example, you might identify the code that reads information for
a single employer, check to see if the
employer is already in the tree, and add a new employer or
update the information in the existing object. Specifics will depend on
how you structure your program, of course.
Do not document every line of code!
- Provide additional documentation for particularly complex sections
of code. If the reader is likely to think "huh?" when trying to understand
what you did, enlighten them!
- Turn in a performance report with your program that
describes what, if any, bugs it contains.
Unreported bugs will be penalized more heavily than reported bugs.
What to Turn In
Zip your prog2 directory
and e-mail it to me by the deadline. Turn in
hardcopy of any classes you modified along with
your performance report.