Assignemnt #122 and DataFile

Code

/// name: Leila Ordukhani
/// period: 6
/// program name: One Hundred and three Program
/// file name: DataFile.java
/// date finished: 5/17/16

    import java.io.File;
    import java.util.Scanner;
    
    public class DataFile {
    
        public static void main(String[] args) throws Exception {
    
            String name;
            int a, b, c, sum;
    
            System.out.print("Getting name and three numbers from file.....");
    
            Scanner fileIn = new Scanner(new File("name-and-numbers.txt"));
    
            name = fileIn.nextLine();
            a = fileIn.nextInt();
            b = fileIn.nextInt();
            c = fileIn.nextInt();
    
            fileIn.close();
    
            System.out.println("done.");
            System.out.println("Your name is: " + name);
            sum = a + b + c;
            System.out.println(a + " + " + b + " + " + c + " = " + sum);
        }
    }
    
    //This could cause a problem because you need to change the numbers everytime you want to run it
    to receive different results

  

Picture of the output

Assignment 122