Assignemnt #128 Summing Several Numbers from Any File

Code

     ///Name: Prooz Fereydouni
    ///Period: 7
    ///Project Name: Summing Several Numbers from Any File
    ///File Name: SSNFAF.java
    ///Date: 5/28/2016
    
  import java.util.Scanner;
    import java.io.File;
    
    public class SSNFAF {
        
        public static void main(String[] args) throws Exception{
            
            Scanner kb = new Scanner(System.in);
            
            String txt;
            System.out.println("What file would you like to scan? ");
            txt = kb.next();
            
            Scanner scan = new Scanner(new File(txt));
            int b=0;
            while (scan.hasNext()) {
                
                int a = scan.nextInt();
                b = b + a;
                System.out.print(a + " ");
            }
            System.out.println("");
            System.out.println("The total is " + b + ".");
        }
    }



    

Picture of the output

assignment128