Assignment #125 and Numbers From any File
Code
///Name: Tim Gibson
///Period: 6
///Project Name: Summing Numbers from any file
///File Name: Any.java
///Date Finished: 1/14/16
import java.util.Scanner;
import java.io.File;
public class Any{
public static void main (String[] args) throws Exception{
Scanner kb = new Scanner(System.in);
String f;
System.out.print("What file would you like to take numbers from?");
f = kb.next();
Scanner file = new Scanner( new File(f));
int a, b, c, d;
a = file.nextInt();
b = file.nextInt();
c = file.nextInt();
d = a + b + c;
System.out.println(d);
}
}
Picture of the output