Assignment #125 Summing Three Numbers from Any File

Code

    /// Name: Koosha Kimelman
    /// Period: 7
    /// Program Name: Summing Three Numbers from Any File
    /// File Name: AnyThreeNumbers.java
    /// Date Completed: 6/3/16
    
    import java.io.File;
    import java.util.Scanner;
    
    public class AnyThreeNumbers {
    
        public static void main(String[] args) throws Exception {
        
            int a, b, c, sum;
            String file;
            
            Scanner k = new Scanner(System.in);
            
            System.out.print("Which file to add numbers from: ");
            file = k.nextLine();
            
            Scanner fileIn = new Scanner(new File(file));
            
            a = fileIn.nextInt();
            b = fileIn.nextInt();
            c = fileIn.nextInt();
            sum = a + b + c;
            
            fileIn.close();
            
            System.out.println("\n" + a + " + " + b + " + " + c + " = " + sum);
        }
    }
    

Picture of the output

Assignment 125