COSC 1320 - C++ Programming
Bob Comer, Professor, CIT/COSC


Assignment 7 - Payroll Version 3.0

Be sure to read through chapters 12 (strings) and 13 (files) before starting this assignment. This is another re-write of your payroll program. The major changes are:

Employee class

You will use your employee class from the previous programming assignment. Change the member variable for the employee name so that you use a C-string instead of a C++ string object. Your C-string should be able to hold names up to 20 characters in length. Then modify your member functions as required to work with the C-string.

Program input

The program input consists of two files - a master file and a transaction file. Your code must work for the 2 input files provided. You may also want to test your program with other input data.

Master file

The master file has one line of input per employee containing:

This file is ordered by ID number. Your code should work for any number of employees up to 100 (use an end-of-file loop to read this file). You can assume that there is exactly one space between the employee ID number and the name. You can also assume that the name occupies 20 columns in the file.

Transaction file (weekly timesheet information)

The transaction file has one line for each employee who worked containing:

This file may have any number of transactions.

Calculations

Program output

The program output will consist of two reports:

Error and Control Report

This report can be printed on the screen or alternatively can be printed to a file.

Payroll Report

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

The final line of the payroll report should print the total amount of gross pay and total amount of net pay for the week.

Requirements/Hints:

  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. You can assume that the Master file does not contain errors (error checking is done by another program). Error checking for the Transaction file is described in the Error and Control Report. You can download sample files here:

master7.txt
trans7.txt

  1. Use C-strings (not the C++ string class) to represent strings in your program.
  2. You should use a class to represent the master file information for one employee.
  3. The Payroll Report must be written to a file.
  4. The master file information should be read into an array.
  5. Do not read and store the transaction information in an array. When you store transactions in arrays, you set a limit on the number of transactions your program can process. For this program, you should be able to read and process transactions one at a time.
  6. Your program might be structured similar to this example program:

http://www.austin.cc.tx.us/comer/1320f04/itemclass.cpp


Return to C++ Home Page

Copyright: 2004 by the Austin Community College
Department of Computer Studies. All rights reserved.
Comments to:
Bob Comer
Last updated: November 18, 2004