Assignemnt #125 Summing Three Numbers from Any File

Code

     ///Name: Prooz Fereydouni
    ///Period: 7
    ///Project Name: Summing Three Numbers from Any File
    ///File Name: STNFAF.java
    ///Date: 5/28/2016
    
import java.io.File;
import java.util.Scanner;

public class STNFAF {

    public static void main(String[] args) throws Exception {
        Scanner kb = new Scanner(System.in);
        System.out.print("Which file would you like to read numbers from : ");
        String num = kb.next();
        if(num.equals("3nums1.txt"))
        {
            Scanner fileIn = new Scanner(new File("3nums1.txt"));
        
            int a = fileIn.nextInt();
            int b = fileIn.nextInt();
            int c = fileIn.nextInt();
            
            int sum = a + b + c;
            
            System.out.println(a + " + " + b + " + " + c + " = " + sum);
        }
        else if(num.equals("3nums2.txt"))
        {
            Scanner fileIn = new Scanner(new File("3nums2.txt"));
        
            int a = fileIn.nextInt();
            int b = fileIn.nextInt();
            int c = fileIn.nextInt();
            
            int sum = a + b + c;
            
            System.out.println(a + " + " + b + " + " + c + " = " + sum);
        }
        else if(num.equals("3nums3.txt"))
        {
            Scanner fileIn = new Scanner(new File("3nums3.txt"));
        
            int a = fileIn.nextInt();
            int b = fileIn.nextInt();
            int c = fileIn.nextInt();
            
            int sum = a + b + c;
            
            System.out.println(a + " + " + b + " + " + c + " = " + sum);
        }
        else
            System.out.println("Wrong Input! choose the name of the file you want to read numbers from");
    }
}



    

Picture of the output

assignment125