Assignment #125 Summing Three Numbers from Any File

Code

    /// Name: John Huh
    /// Period: 6
    /// Program Name: Summing Three Numbers from Any File
    /// File Name: Sum3AnyFile.java
    /// Date Finished: 5/23/2016
    
    import java.io.File;
    import java.util.Scanner;
    
    public class Sum3AnyFile {
    
        public static void main(String[] args) throws Exception {
    
            int a, b, c, sum;
            String file;
            Scanner keyboard = new Scanner(System.in);
            
            System.out.println();
            System.out.print( "Which file would you like to read numbers from: " );
            file = keyboard.next();
            System.out.print("Reading numbers from file \"" + file + "\"");
    
            Scanner fileIn = new Scanner(new File(file));
    
            a = fileIn.nextInt();
            b = fileIn.nextInt();
            c = fileIn.nextInt();
    
            fileIn.close();
            
            System.out.println();
            System.out.println();
            sum = a + b + c;
            System.out.println(a + " + " + b + " + " + c + " = " + sum);
            System.out.println();
        }
    }
    

Picture of the output

Assignment 1