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

public class BadDataDemo {
	public static void main(String [] args) throws Exception {
		Scanner scanner = new Scanner(new File("numbers.text"));

		int total = 0;
		while (scanner.hasNextInt()) {
			try {
				int num = scanner.nextInt();
				if (num < 0) throw new Exception("Negative number " + num + " encountered");
				total += num;
			} catch (Exception e) {
				System.out.println("*** " + e.getMessage());
			}

		}
		System.out.println("total: " + total);
	}
}


		
