Control break report

Objectives

  • Read data from a text file
  • Write data to a text file
  • Correctly end a file input loop when end of file is reached
  • Process control breaks correctly
  • Calculate sums for grouping of input data
  • Implement an algorithm
  • Format output data on a report neatly
  • Test and debug a program

Overview

This assignment involves the creation of a level break report. The data file provided has already been put into the proper sorted order. The format of each record is as follows:

  • department: String
  • employee id: String
  • month: int
  • day: int
  • year: int
  • hours: double

The data file is available on the remote server at: ~dklick/examples/cb1data.txt

The data file is also available here: cb1data.txt.

Requirements

Your task is to read the records in from the data file (cb1data.txt) and produce a report to a file named cbreport.txt.

Although the following technique is "brittle", you may read the data from the input file using the standard input extraction operator. For example, if you wanted to read one whole record in one statement and had the appropriate variables declared, you could write:
infile >> dept >> empID >> month >> day >> year >> hours;

A "priming read" is well-suited for this type of algorithm. A priming read makes a read from input just before a while loop starts, and then has the same read just before the end of the loop body. That type of read works very well when reading from a text file and checking for end-of-file. Instead of trying to read all of the fields from a single record though, it is better to just use the first field for the priming read, and read the remainder of the fields for that record as the first line within the loop. Example:

The report you produce should match the sample report exactly, including ALL formatting and spacing. A sample of the report is available on the remote server at: ~dklick/examples/cbreport250.txt. You can compare your output file to the reference outout file using the following command:
diff report.txt ~dklick/examples/cbreport250.txt
That command will display differences between the two files. If there are no differences, then your report is correct.

You have been given an algorithm to implement. There are some ambiguities to simulate a real life situation - but no errors that the instructor is aware of. You are required to use ostream manipulators (left, right, setw, setprecision, fixed, showpoint, etc.) to get the correct output formatting for this project.

Sample Output

Pseudocode

To make life even easier for you, here's the pseudocode for your program:

Rubric

  • 3 points for comments at the start of the source code which contain program name, student name, assignment, date, course, and a brief program description
  • 2 points for correctly following coding conventions (indentation, naming rules, NO tabs, etc.)
  • 5 points for correctly reading the input (data) file
  • 5 points for correctly writing to the output (report) file
  • 10 points for having the report formatting match exactly using ostream manipulators
  • 25 points for correctly implementing the algorithm given in this assignment