Removing uneeded file.
[and.git] / PC^2 / pc2 / samps / isumit.java
blobdf24073d9892bc3c45c76ea016b20277ba1fabd2
1 import java.io.*;
3 //
4 // File: isumit.java
5 // Purpose: to sum the integers from stdin
6 // Author: pc2@ecs.csus.edu or http://www.ecs.csus.edu/pc2
7 //
8 // Thu Oct 2 20:25:28 PDT 2003
9 //
10 // $Id: isumit.java,v 1.1 2005/03/06 05:34:39 laned Exp $
13 public class isumit {
14 public static void main(String[] args)
16 try
18 BufferedReader br = new BufferedReader (
19 new InputStreamReader (System.in), 1);
21 String line;
22 int sum = 0;
23 int rv = 0;
24 while((line = br.readLine()) != null)
26 rv = new Integer(line.trim()).intValue();
27 if (rv > 0)
28 sum = sum + rv;
29 // System.out.println(line);
31 System.out.print("The sum of the integers is ");
32 System.out.println(sum);
34 catch(Exception e)
36 System.out.println("Possible trouble reading sumit.dat");
37 System.out.println("Message: "+ e.getMessage());
42 // eof isumit.java $Id: isumit.java,v 1.1 2005/03/06 05:34:39 laned Exp $