COSC 1320 - C++ Programming and
ITSE 1307 - Introduction to C++ Programming
Bob Comer, Professor of Computer Studies
Assignment 5 - Payroll Version 1.0
Be sure to read through Chapter 8 sections 8.12 - 8.15 (Arrays of Structs and Classes) before starting this assignment. Your job is to write a payroll program for Armadillo Automotive Group.
Note: There is a bug in the Microsoft Visual C++ 6.0 compiler that will affect this assignment. Given the code: When you attempt to input the name, you have to press the enter key twice to get the program to accept the string. There is more information on the problem here: http://support.microsoft.com/default.aspx?scid=kb;en-us;240015 If you are brave enough to attempt to fix the problem, be careful! Make a backup copy of the header file before attempting to edit it. |
Program input
For a payroll program you would normally input the data from files, but in this first version 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++ struct 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 structs. 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 output to a file. It should be in a tabular (row and column) format with each column clearly labeled with a column heading. All dollar amounts should be formatted with 2 decimal places. Note: do not use tabs between the columns - use the setw manipulator to set the column width so that you can line up columns of numbers on the decimal point. 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 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
Copyright: Ó2005 by the Austin Community College
Department of Computer Studies. All rights reserved.
Comments to: Bob Comer
Last updated: August 25, 2005