Advertisement
Guest User

yo

a guest
Feb 12th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.io.*;
  3.  
  4. class ch15ex5a
  5. {
  6. public static void main (String[] args) throws IOException
  7. {
  8. File fileIn = new File("test/myData.txt");
  9. Scanner scan = new Scanner( fileIn );
  10.  
  11. int num, sum=0, max=0;
  12.  
  13. while( scan.hasNextInt() )
  14. {
  15. num = scan.nextInt();
  16. sum = sum + num ;
  17.  
  18. }
  19.  
  20. System.out.println( "Sum is "+ sum );
  21.  
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement