Assignemnt #132
Code
/// Name: Connor Siri
/// Period: 7
/// Program Name: Summing
/// File Name: Summing.java
/// Date Finished:3/31/2016
import java.io.File;
import java.util.Scanner;
public class Summing {
public static void main(String[] args) throws Exception {
Scanner kb = new Scanner(System.in);
String file;
System.out.print("Which File do you want? ");
file = kb.next();
Scanner reader = new Scanner(new File(file));
int total = 0;
while (reader.hasNext()) {
int a = reader.nextInt();
System.out.print(a + " ");
total = total + a;
}
System.out.println("Your total is " + total);
}
}
Picture of the output