Assignment 125; SumThreeAny
Code
// Donovan Rich
// Period 6
// Summing Three Numbers from Any File
// SumThreeAny.java
// 6/9/2016
import java.io.File;
import java.util.Scanner;
public class SumThreeAny {
public static void main(String[] args) throws Exception {
int a, b, c;
Scanner keyboard = new Scanner(System.in);
System.out.print("What file do you want to open?");
String filename = keyboard.next();
Scanner fileIn = new Scanner(new File(filename));
a = fileIn.nextInt();
b = fileIn.nextInt();
c = fileIn.nextInt();
fileIn.close();
System.out.println(a + " + " + b + " + " + c + " = " + (a+b+c) );
}
}
Picture of the output