UMBC CMSC 201 Spring '01 | CSEE | 201 | 201 S'01 | lectures | news | help |
CMSC 201 Employee Updates Out: Monday 4/9/01 The design document for this project,
design4.txt , |
The objective of this assignment is to give you practice with project and function design. It will also give you an opportunity to work with file pointers, dynamic memory allocation, command-line arguments, and string library functions.
You will be provided with two input files for this project. The first (employees.dat) will contain initial data about employees at a company, including each employee's name, job title (prefixed by Junior, Midlevel, Advanced, or Senior), number of years experience, salary (in $1000), and degree (none, BS, MS, or PhD). Each line of the file holds one piece of data; the first line of the file contains an integer representing how many employees appear in the file.
The second (updates.dat) will contain data to update the information provided
in the first file. Each line of this file contains an employee name followed
by an amount (in $1000) by which to increase that employee's salary. (Some
employee names from the first file may not appear in the second file.) When an
employee is given a raise, it is possible that their job title prefix will change.
The prefix to their job title (Junior, Midlevel, Advanced, or Senior) is
determined by the following score quantity:
(salary - 25)/(years with company) + (0 for no degree, 1 for BS, 2 for MS, 3 for PhD)
If this score is less than 3, the prefix should be Junior; at least 3 but less than 6, the prefix should be Midlevel; at least 6 but less than 9, the prefix should be Advanced; and at least 9, the prefix should be Senior. However, employees should never be demoted; that is, a job title prefix should only ever be updated to a higher one, regardless of the above formula. Senior is the highest, followed by Advanced, Midlevel, and Junior, in that order.
You can view sample employees.dat and updates.dat files to examine their contents and see their formats.
You may copy these files into your account by using the following commands:
cp /afs/umbc.edu/users/s/b/sbogar1/pub/cs201/P4Data/employees.dat .
cp /afs/umbc.edu/users/s/b/sbogar1/pub/cs201/P4Data/updates.dat .
However, your project should work for any such input files. The graders will
be using their own input files to test your project.
Design and code a project that will allow you to specify the input files on the command line, read in the information from the input files using file pointers, perform the necessary updates to job titles, and print out all updated information to an output file named on the command line.
irix1[1]% a.out employees.dat updates.dat outputfilename
If they deviate from this, print an error message informing them of the correct usage, and then quit the program. Also, if any of the 3 files cannot be opened in the appropriate way, print a specific error message regarding this, and quit the program.
You are to use separate compilation for this project, so you will be
submitting a minimum of three files.
Your C source code file that
contains main() MUST be called proj4.c. I would expect
that you would also have files called employees.c and employees.h, but you
may choose to have additional .c and .h files.
To submit your project, type the following at the Unix prompt. Note that the project name starts with uppercase 'P'.
submit cs201 Proj4 proj4.c employees.c employees.h (and possibly other files, separated by spaces)
To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj4
Sunday, 09-Apr-2001 22:00:00 EDT