File I/O Part 1 #124 (Summary of conclusion...)

Code

/// Name: Amir Salehi
/// Period: 7
/// Program Name: Summing Three Numbers
/// File Name:STN.java
/// Date Finished: 5/25/2016

    
    import java.io.File;
    import java.util.Scanner;
    
    public class STN
    {
        public static void main (String[] args) throws Exception
        {
            int a, b, c, sum;
            
            System.out.println( "Reading numbers from file \"3nums.txt\" .... " );
            
            Scanner fileIn = new Scanner(new File("3nums.txt"));
            
            a = fileIn.nextInt();
            b = fileIn.nextInt();
            c = fileIn.nextInt();
            
            fileIn.close();
            
            sum = a + b + c;
            System.out.println( a + " + " + b + " + + " + c + " = " + sum );
        }
    }





    

Picture(s) of the output

Assignment 7

Back to Homepage