Her boss, Ms. Gotta Haveit Now, assigned her the task of computing the hours worked by each employee. Under pressure from the Pentagon to better document work hours, she gave Ms. Ima Late three days to write the program. Unfortunately, Ms. Ima Late did not use her middle name enough and failed to complete the task in time. Her boss fired her, but Ms. Late was able to erase her hard disk before she left.
In a bind, Ms. Gotta Haveit Now turns to you to complete the program. She explains that the program's input consists of a file of lines, each listing the employee's Social Security number, starting time, and ending time (listed in military time, of course). The program's output is to be stored in a file having each line list the Social Security number and the total hours, minutes, and seconds worked by that employee that day. As an example of the input the program will read, she gives you last week's timesheets; as an example of output the program should produce, she gives you times she computed by hand. The program should prompt its user for the names of the input and output files.
Although Ms. Ima Late erased her hard disk, technical support was able to extract parts of the file containing her program. Ms. Now gives you these fragments, together with her comments. Since Ms. Late's program had already been approved by government inspectors (on temporary leave to the Pentagon from the Department of Energy public relations division) even though it was not yet finished (!!), Ms. Now requires you to use all the code fragments so she does not have to complete the bureaucratic paperwork again.
P.S. As Ms. Now walks away from your cubicle, you hear her mutter, "I hate reference variables. A mark of a good programmer is to use them only when necessary." Try to write your code in a way that will convince your new boss that you are a good programmer.
Be sure to use all the code given you.
You may also reuse code from any of the examples we have done in class, most of which are available via the sample programs Web page.
bool readIntInRange(ifstream& inStr, int& result, const int min, const int max) { // ">> dec" is needed because some systems otherwise think // that an integer starting with 0 is octal return ((inStr >> dec >> result) && result >= min && result <= max); }
(If you haven't already started making changes to the code, you can obtain a revised copy here.)