Removing uneeded file.
[and.git] / PC^2 / pc2board / samps / sumit.java
blobdcecbf3745caad871a38b4baf789fba7f3fa86bb
1 import java.io.*;
3 //
4 // File: sumit.java
5 // Purpose: to sum the integers in the file sumit.dat
6 // Author: pc2@ecs.csus.edu or http://www.ecs.csus.edu/pc2
7 //
8 // $Id: sumit.java,v 1.2 2005/03/06 05:19:05 laned Exp $
9 //
11 public class sumit {
12 public static void main(String[] args)
14 try
16 RandomAccessFile file = new RandomAccessFile("sumit.dat", "r");
17 String line;
18 int sum = 0;
19 int rv = 0;
20 while((line = file.readLine()) != null)
22 rv = new Integer(line.trim()).intValue();
23 if (rv > 0)
24 sum = sum + rv;
25 // System.out.println(line);
27 System.out.print("The sum of the integers is ");
28 System.out.println(sum);
30 catch(Exception e)
32 System.out.println("Possible trouble reading sumit.dat");
37 // eof sumit.java $Id: sumit.java,v 1.2 2005/03/06 05:19:05 laned Exp $