// Allison Obourn, CSE 142 // Reads hours worked for several TAs and reports their overall hours worked // stores the result n a file 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")); PrintStream output = new PrintStream(new File("output.txt")); while(input.hasNextLine()) { String line = input.nextLine(); processPerson(line, output); } } // reads and reports hours worked for a single TA public static void processPerson(String line, PrintStream output) { Scanner lineScan = new Scanner(line); int id = lineScan.nextInt(); String name = lineScan.next(); double totalHours = 0; int days = 0; while(lineScan.hasNextDouble()) { totalHours += lineScan.nextDouble(); days++; } output.println(name + " (ID#" + id + ") worked " + totalHours + " hours (" + totalHours / days + " hours/day)"); } }