// Variation of HoursWorked that outputs summary to a file

import java.io.*;
import java.util.*;

public class HoursWorked3 {

	// processes the give String(ID, name, and hours worked)
	public static void processLine(String text, PrintStream output) {
		Scanner data = new Scanner(text);
		int id = data.nextInt();
		String name = data.next();
		double sum = 0.0;
		while (data.hasNextDouble()) {
			sum += data.nextDouble();
		}
		System.out.printf("Total hours worked by %s (id#%d) = %.2f\n", name, id, sum); 
		output.printf("Total hours worked by %s (id#%d) = %.2f\n", name, id, sum);
	}
	
	public static void main(String[] args) throws FileNotFoundException {
		Scanner input = new Scanner(new File("hours3.dat"));
		PrintStream output = new PrintStream(new File("summary.dat"));
		
		while (input.hasNextLine()) {
			String text = input.nextLine();
			processLine(text, output);
		}
 
	}
}