// Allison Obourn
// CS& 141, Winter 2021
// Lecture 11

// Reads a file containing employee work information. Each line of the file is in
// the format: <id number> <employee name> <hours1> <hours2> ...
// There will always be one id number and one name per line but there can be any 
// number of hours. Outputs each employee's name, id number, total hours worked 
// and average hours per day. 

import java.util.*;
import java.io.*;

public class Hours {
   public static void main(String[] args) throws FileNotFoundException {
      Scanner input = new Scanner(new File("hours.txt"));
      while (input.hasNextLine()) {
         String line = input.nextLine();
         Scanner lineScan = new Scanner(line);
         int id = lineScan.nextInt();
         String name = lineScan.next();
         double hours = 0;
         int count = 0;
         // add up the rest of the numbers on the line
         while(lineScan.hasNextDouble()) {
            hours += lineScan.nextDouble();
            count++;
         }
         System.out.println(name + " (ID#" + id + ") worked " + hours + " (" + 
                            (hours / count) + " per day)");
      }

   }
}