CPSC 220 Fall 2007
Program 1: Employment Data
Background
The Commonwealth of Virginia is divided into 21 planning districts.
Planning District Commissions have been established with
the following purpose, as described in the Code of Virginia, Section 15.2-4207:
"...to encourage and facilitate local government cooperation and state-local cooperation in addressing on a regional basis problems of greater than local significance. The cooperation resulting from this chapter is intended to facilitate the recognition and analysis of regional opportunities and take account of regional influences in planning and implementing public policies and services.
The planning district commission shall also promote the orderly and efficient development of the physical, social and economic elements of the district by planning, and encouraging and assisting localities to plan, for the future."
(Information from An Introduction to Planning District Commissions and the
Roanoke Valley-Allegheny Regional Commission, http://www.rvarc.org/about.htm.)
One such planning commission
is the Roanoke Valley-Allegheny Regional Commission (RVARC), located
on Luck Avenue in Roanoke. Among its many functions, the RVARC uses
employment data collected by the Virginia Employment Commission (VEC) to
identify areas of economic growth in the region. The VEC data
provides the
following information about each employer in the region for each quarter
of each year:
- Federal code for the city or county in which the employer is located (FIPS)
- Federal code for the type of company (SIC codes -- here's
the list if you're interested)
- Trade name, if different from the legal name
- Legal name
- Mailing address (street, city, state, zip, and extended zip). This
could be local or could be for a headquarters or processing center
located elsewhere.
- Physical Address (street, city, state, zip, and extended zip). This
will be in the region.
- Number of people employed for each month in the quarter
The RVARC faces a number of challenges in processing the data it receives
from the VEC. One such challenge is that many companies have multiple
locations, and for most purposes the RVARC would like to combine all
locations for a single company.
Your assignment is to write a Java program that takes a file containing this
data,
aggregates employment information for employers with multiple
locations, and answers queries about the aggregated data. Requirements
for input, output, and program structure are given below.
Input
Your program should prompt the user for the name of the data file to use.
You can test your program
on file employ99-2.dat, which contains the data
described above for the second quarter of 1999. The data for
each company is stored in 21 comma-separated fields. Download and open
the data file and identify exactly what the fields are -- the first line
contains headers for
each field that should help. You can assume that any data file used
will be in the same format, including the header row.
After prompting for the data file, your program should repeatedly prompt
the user for the name of an employer, then display information
for that employer as described below.
Allow the user to look up as many companies as he or she wishes, with some
nice way to exit the program when finished.
Output
For each company requested by the
user, the following information should be displayed
to the standard output, neatly labeled and formatted:
- Trade name, if different from legal name
- Legal name
- Type of company (SIC code for now)
- Total number of people employed for each month in the quarter
- Number of physical locations
- Physical address (street, city, state, zip, and extended zip) for each
location, and number of people employed at each address. These should
sum to your total above.
In doing searches, if the trade name is different from the legal name,
match the trade name; otherwise match the legal name.
Program Structure
Structure your program around the following classes:
- LinkedBinarySearchTree -- implements a classic binary search tree. Use
the code from the text (you already downloaded this in the jss2 directory),
but note that it relies on the find and contains methods from the LinkedBinaryTree class, which are O(N). Rewrite these so that they use the BST properties
to produce O(log N) searches (assuming a balanced tree). You may need to
complete some of the other methods as well.
- Employer -- stores the information for a single employer.
Note that you will need to be able to store multiple addresses and employment
data for each address in addition to total employment data.
Also, to facilitate searching, you might
want to store an additional string that contains the trade name
if there is one, otherwise the legal name.
Of course, you will probably need other classes as well; these are just
to get you started.
Your program should operate in two phases:
- Build the tree -- Create a BST (initially empty) of Employer objects.
Each time you read an employer from the file,
check the tree to see if
this employer is already there. If not, add it to the tree. If so, do
not make a new entry in the tree; simply update the existing
entry with the additional
employment and address data.
- Respond to user queries -- When the user asks for information
about an employer, find that
employer in the tree and display the information. No calculations
should be required at this time. If the employer is not in the tree,
print a helpful message saying so.
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 how you tested your program and what, if any, bugs you found.
Unreported bugs will be penalized more heavily than reported bugs.
What to Turn In
Embed your jss2 directory in your prog1 directory, zip the whole
thing and e-mail it to me by the deadline. Turn in
hardcopy of any classes you modified along with
your performance report.