// Processes TA hours given in the following format: // 123 Kim 12.5 8.1 7.6 3.2 import java.io.*; import java.util.*; public class UnderpaidTAs { public static void main(String[] args) throws FileNotFoundException { File file = new File("hours.txt"); Scanner input = new Scanner(file); PrintStream output = new PrintStream("hours_out.txt"); while (input.hasNextLine()) { String line = input.nextLine(); Scanner lineScanner = new Scanner(line); int taID = lineScanner.nextInt(); String taName = lineScanner.next(); double hours = 0.0; int days = 0; while (lineScanner.hasNextDouble()) { hours += lineScanner.nextDouble(); days++; } output.printf("%s (ID#%d) worked %.1f hours (%.2f hours/day)\n", taName, taID, hours, hours / days); } } }