COSC 1320 - C++ Programming and
ITSE 1307 - Introduction to C++ Programming
Bob Comer, Professor of Computer Studies


Assignment 6 - Payroll Version 2.0

Be sure to read all of Chapters 8 and 9, and Chapter 11 sections 11.1 and 11.4 before starting this assignment. Your job is to update your payroll program for Armadillo Automotive Group to use C++ classes instead of structs. At a minimum, you must define a class to hold the master file information for one employee. Optionally, you may create other classes, such as a class to hold timesheet information.

Employee class

Create a class to represent the master file information for one employee. The class should not have data members for any timesheet information or any data that can be calculated from the master file information (that is, it should only contain the information shown below). The data members of the class should be private members. Your class should include the following public functions:

Program input

The input will be the same as for program 5. You will input the data from the keyboard. The program input should be in 2 parts: employee master information and timesheet information.

Employee Master information

The employee master information consists of the following data:

Note: Use the C++ string class for the employee name. Use a C++ class object to hold the employee master information for one employee.

Timesheet information

Assume that there are exactly 5 employees. Your program should first input the employee master information into an array of class objects. Then use a separate loop to do the payroll processing for each employee (input the employee's hours worked and calculate their pay (see the example program dialog below).

Calculations

Input validation

The input should be checked for reasonable values. If a value is not reasonable, your program should print an informative error message and ask the user to re-enter the value.

Program output - Payroll Report

The payroll report should be printed to a file. It should be in a tabular (row and column) format with each column clearly labeled with a column heading. Print one line for each transaction that contains:

The final lines of the payroll report should print the total amount of gross pay and total amount of net pay for the week (the total for all employees).

Your program dialog should look something like this example (user input is shown in bold).

Enter information for employee 1
Employee id: 22
Employee name:
Cindy Burke
Pay rate: 15.00
Dependents: 1
Type: 0

Enter information for employee 2
Employee id: 42
Employee name:
J. P. Morgan
Pay rate: 12.50
Dependents: 0
Type: 0
...
(input employee master information for last 3 employees)
...
Enter timecard information for each employee:
Hours worked for Cindy Burke: 40.0
Hours worked for J. P. Morgan: 39.5
...
(input timecard information for last 3 employees)
...

Other Requirements

  1. Global variables are variables that are declared outside any function. Do not use global variables in your programs. Declare all your variables inside functions.
  2. Use the C++ string class to represent strings in your program.
  3. You should use a class to represent the employee master information for one employee. Note: you should NOT include Timecard information in this class. Timecard information may change from one pay period to the next while employee master information usually does not. In other words, an employee's master information and information about a specific paycheck are 2 different things and logically should not be combined in the same class.
  4. Write the Payroll Report to a file.
  5. The employee master information should be read into an array of class objects.
  6. The timecard information (hours worked) does not need to be stored in an array.


Return to C++ Home Page

Copyright: Ó2005 by the Austin Community College
Department of Computer Studies. All rights reserved.
Comments to:
Bob Comer
Last updated: August 25, 2005