Assignemnt #128 Summoning Several Numbers From Any File

Code

    ///Name: Joshua Pell
    ///Period: 6
    ///Project Name: Summoning Several Numbers From Any File
    ///File Name: summonSevNumbers.java
    ///Date: 6/3/2015
    
import java.util.Scanner;
import java.io.File;

public class summonSevNum
{
    public static void main(String[] args) throws Exception
    {
        
        Scanner scan = new Scanner( System.in );
        int total= 0;
        
        System.out.print( "Which file would you like to read numbers from: " );
        String moniker = scan.next();
        System.out.println( "Reading numbers from \"" + moniker + "\"" );
        Scanner inFile = new Scanner( new File(moniker));
        
        while ( inFile.hasNextInt() )
        {
            int num = inFile.nextInt();
            System.out.print( num + " " );
            total = total + num;
        }
        System.out.println();
        System.out.println( "Total is " + total);
    }
}
    

Picture of the output

Assignment 128