UMBC CS 201, Spring 01
UMBC CMSC 201 Spring '01 CSEE | 201 | 201 S'01 | lectures | news | help

CMSC 201
Programming Project Four

Employee Updates

Out: Monday 4/9/01
Due: Before Midnight, Wednesday 4/25/01

The design document for this project, design4.txt ,
is due: Before Midnight, Sunday 4/15/01

The Objective

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.

The Background

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.

The Task

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.

The Specifications

Sample Run

[sunserver1] /home/grad1/bbenin1>cat employees.dat 6 BrettFavre SeniorMarketer 5 50 none DanMarino JuniorWriter 5 50 BS BillCowher MidlevelEngineer 8 75 MS EddieGeorge MidlevelTeacher 5 20 BS WayneChrebet AdvancedManager 10 55 BS MartinGramatica JuniorAnalyst 5 100 none [sunserver1] /home/grad1/bbenin1>cat updates.dat WayneChrebet 50 BillCowher 100 RandyMoss 25 BrettFavre 5 DanMarino 10 [sunserver1] /home/grad1/bbenin1>a.out employees.dat updates.dat Usage: a.out <inputfile1> <inputfile2> <outputfile> [sunserver1] /home/grad1/bbenin1>a.out employees.dat updates.dat employees.out Error: employee RandyMoss not found. [sunserver1] /home/grad1/bbenin1>cat employees.out BrettFavre: SeniorMarketer, 5 years with company, salary $55,000 with degree none. DanMarino: AdvancedWriter, 5 years with company, salary $60,000 with degree BS. BillCowher: SeniorEngineer, 8 years with company, salary $175,000 with degree MS. EddieGeorge: MidlevelTeacher, 5 years with company, salary $20,000 with degree BS. WayneChrebet: SeniorManager, 10 years with company, salary $105,000 with degree BS. MartinGramatica: JuniorAnalyst, 5 years with company, salary $100,000 with degree none.

Submitting 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


CSEE | 201 | 201 S'01 | lectures | news | help

Sunday, 09-Apr-2001 22:00:00 EDT