Assignment #125 and Summing Three Numbers From Any File

Code

    /// Name: Lauren Baird
    /// Period: 7
    /// Program Name: Summing Three Numbers From Any File
    /// File Name: Summing3Numbers2.java
    /// Date Finished: 3/22/2016
    
    import java.io.File;
    import java.util.Scanner;
    
    public class Summing3Numbers2
    {
        public static void main (String[] args) throws Exception
        {
            Scanner keyboard = new Scanner(System.in);
            int a, b, c, sum;
            String again;
            
            System.out.println();
            
            do
            {
                System.out.print( "Which file would you like to read numbers from: " );
                String answer = keyboard.next();
    
                if ( answer.equals("3nums1.txt"))
                {
                    Scanner fileIn = new Scanner(new File("3nums1.txt"));
    
                    System.out.println( "Retrieving information from \"3nums1.txt\" ... " );
    
                    a = fileIn.nextInt();
                    b = fileIn.nextInt();
                    c = fileIn.nextInt();
    
                    fileIn.close();
    
                    sum = a + b + c;
                    System.out.println( a + " + " + b + " + + " + c + " = " + sum );
                }
    
                if ( answer.equals("3nums2.txt"))
                {
                    Scanner fileIn = new Scanner(new File("3nums2.txt"));
    
                    System.out.println( "Retrieving information from \"3nums2.txt\" ... " );
    
                    a = fileIn.nextInt();
                    b = fileIn.nextInt();
                    c = fileIn.nextInt();
    
                    fileIn.close();
    
                    sum = a + b + c;
                    System.out.println( a + " + " + b + " + + " + c + " = " + sum );
                }
    
                if ( answer.equals("3nums3.txt"))
                {
                    Scanner fileIn = new Scanner(new File("3nums3.txt"));
    
                    System.out.println( "Retrieving information from \"3nums3.txt\" ... " );
    
                    a = fileIn.nextInt();
                    b = fileIn.nextInt();
                    c = fileIn.nextInt();
    
                    fileIn.close();
    
                    sum = a + b + c;
                    System.out.println( a + " + " + b + " + + " + c + " = " + sum );
                }
    
                System.out.println();
    
                System.out.print( "Would you like to read numbers from another file? " );
                again = keyboard.next();
                
            } while ( again.equals("yes"));
            
            if ( again.equals("no"))
                System.out.println( "goodbye" );
            
        }
    }  
    

Picture of the output

Assignment #125 Assignment #125 Assignment #125 Assignment #125