Assignment #125 Summing three numbers from any file

Code

    /// Name: DeeJay Cerezo
/// Period: 7
/// Program Name: Sumany
/// File Name: Summany.java
/// Date Finished: 5/13/2016


import java.io.File;
import java.util.Scanner;

public class Sumany {

    public static void main(String[] args) throws Exception {

        int a, b, c, sum;
        String fileName = "";
        Scanner keyboard = new Scanner(System.in);

        while (!fileName.equals("exit"))
        {
            System.out.print("Which file would you like to read from?\n>");
            fileName = keyboard.next();

            if (!fileName.equals("exit"))
            {
                System.out.print("Reading numbers from file \"" + fileName + "\":\n\n>");

                Scanner fileIn = new Scanner(new File(fileName));

                a = fileIn.nextInt();
                b = fileIn.nextInt();
                c = fileIn.nextInt();

                fileIn.close();

                System.out.println("done.");
                sum = a + b + c;
                System.out.println(a + " + " + b + " + " + c + " = " + sum);
            }
        }
    }
}




    
    

Picture of the output

Assignment