Assignemnt #128 and Summing Numbers

Code

/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Summing Numbers
/// File Name: SummingNumbers.java
/// Date Finished: 5/31/2016

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

public class SummingNumbers
{
    public static void main(String[] args) throws Exception
    {
        Scanner kb = new Scanner(System.in);
        
        String fn;
        
        System.out.println("Which file to open? ");
        System.out.print("> ");
        fn = kb.next();
        
        while( fn.equals("4nums.txt") || fn.equals("5nums.txt") || fn.equals("6nums.txt") || fn.equals("7nums.txt") || fn.equals("8nums.txt"))
        {
            
            Scanner reader = new Scanner(new File(fn));
            int total = 0;
            while( reader.hasNext())
            {
                int a = reader.nextInt();
                System.out.print(a + " ");
                total = total + a;
            }
            
            System.out.println("Total: " + total);
            System.out.println("");
            System.out.println("Which file would you like to add from?");
            System.out.print("> ");
            fn = kb.next();
            System.out.println("");
        }
    }
}
    

Picture of the output

Assignment 8