6.3 Quiz Instructions

Write a program that tallies the number of hours worked for each employee in a department and also displays the total number of hours worked by the department. This is identical to yesterday's quiz except the employee data includes an employee ID number at the start of the employee info line.

Use nextLine() to read in the entire employee line of data, then use a String Scanner to pick out the individual employee data items listed below. Make sure you use methods to eliminate redundancy and package up modular functionality.

The department information is in a file, one per department. The department file information structure is:

  • 1st line: the name of the department
  • one line per employee:
    • employee ID (int) followed by...
    • name (string) followed by...
    • five doubles representing the hours worked each day of the week

The department files are listed below (save all these files in your work folder).

Please note the first file (FileDoesNotExist.txt) does not ... you guessed it ... exist. Your program must deal gracefully with this case, i.e. not die with an unhandled exception. So, to be clear, you will NOT have a file named FileDoesNotExist.txt in your working folder.

Name your class "<your name>_FileLineQuiz" and submit the source code to me via DropItToMe

The program must produce the exact output found in: (make sure you use the output comparision tool!)

The program will process each file by:

  1. Printing out a dashed line separator
  2. If the file does not exist:
    • Display the line "<filename> does not exist!"
  3. If the file does exist:
    • Display the line "Hours worked for the <dept name> department:"
    • For each employee, display the information (id, name and hours worked for the week) on a separate line preceeded by a tab
    • Display the line "Total hours for department: <#>"
  4. Display a blank line

Round numeric results to two decimal places (may use printf and %.2f).

See the expected output file for a reference.

Quiz Grading

The quiz is worth 35 points.

This is pretty simple...you get 100% if your output exactly matches the expected output...and...0% if it has ANY differences.

Make sure you get all the spelling, capitalization, punctuation, spacing, etc. correct! Hint: copy-n-paste is a wonderful thing! :)