Project 3 - Data Processing

Due - Wednesday, April 4, 2007

The goal of this project is to give you experience using iteration, file i/o, classes, and lists. You will write a program that reads from a file information about employees of an organization and their pay rates. For each employee, your program will create an object to store the employee's information and insert the object into a list. Your program will then calculate the amount each employee will receive on his/her paycheck.

The input file from which your program will read will contain one line for each employee. Each line will have five space-delineated fields denoting the first name, last name, title, yearly salary, and pay frequency. The frequency denotes the number of paychecks the employee receives in a year (e.g., 12 would mean the employee was paid every month, 10 would mean the employee was only paid for 10 months, and 24 would mean the employee was paid twice per month). An example would look as follows:

FirstName:Bob LastName:Smith Title:Staff Salary:45000 Frequency:12
FirstName:Ann LastName:Wang Title:Professor Salary:80000 Frequency:10
FirstName:Alice: LastName:Banerjee Title:RA Salary:20000 Frequency:24


For each line in the file, your program will read the line, parse it to extract the five pieces of information, and create an Employee object. Your Employee class will have data members to hold the first name, last name, title, salary, and frequency respectively. You will then insert the Employee object into a list contained in an EmployeeDB object.

Once you have inserted all employee information into your database, you will calculate the pay for each employee as described below and save the result to a file.

Part 1 - 75%

For part 1, implement the following:
Employee - The Employee class will have six data members: firstName, lastName, title, salary, payFrequency, and currentPayAmount. It will also have the following methods: EmployeeDB - The EmployeeDB class will have one data member: a list that will hold Employee objects. It will also have the following methods: Driver - The driver will prompt the user for the name of the file where the employee information it stored. It will then create a new EmployeeDB object passing in the file name. Next, it will invoke the calculateCheckAmounts method on the EmployeDB object. Finally, it will prompt the user for the name of the file where the calculated information should be stored and pass the input to the saveToFile method of the EmployeeDB object.

Part 2 - 10%

For part 2, you will modify the Employee class such that it appropriately deducts taxes from the employee's pay. You will add the following method the the Employee class: You will also modify the calculatePay method such that it first invokes getTaxRate to determine the appropriate rate of taxation and then deducts the appropriate amount from the pay.

Part 3 - 15%

For part 3, you will enable the user to give bonuses to specific employees. In your driver, you will implement a loop between the portion of the program that invokes the calculateCheckAmounts method and the portion that saves the results to a file. The loop will enable the user to give bonuses to several employees. It will prompt the user for the name (first and last) of the employee to which it wishes to give the bonus and the amount of the bonus. It will then invoke a findAndGiveBonus method on the EmployeeDB object, passing in the first name, last name, and bonus amount. The findAndGiveBonus method of the EmployeeDB will search the list of Employee objects until it finds the object containing the specified first and last name. You may want to implement one or more methods to compare the specified first and last name to the first and last name contained in an Employee object. Once it the findAndGiveBonus method has found the correct Employee, it will invoke a method that will increase the pay by the bonus amount. Be sure to handle the situation in which the specified Employee is not found.

Implementation Requirements and Hints

  1. Make sure to implement and test your program in small increments. For example, you can begin by implementing the Employee class. Then, implement the EmployeeDB class one method at a time.
  2. You should refer to the python library reference (http://docs.python.org/lib/string-methods.html) for information about parsing strings. In particular, you will probably need the split method.
  3. You do not need to submit each part separately. If you complete parts 2 and/or 3, you can submit one working program that supports the functionality for the part you have completed.

Due 1:30PM, Wednesday, April 4, 2007

  1. Complete and submit your working code. Turn in a hard copy in class and place a copy of your .py files in /home/submit/cs110-s07/username.
  2. Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
  3. Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other source including another text book, a web page, or another student (current or former). You must provide citations for any sources you have used in designing and implementing your program.
Sami Rollins