Prog 128: Summoning Several Numbers from Any File
//Name: Ilana Levy
//Period: 5
//Program Name: Summoning Several Numbers from Any File
//File Name: summonSevNum.java
//Date Finished: 2/22/2016
import java.util.Scanner;
import java.io.File;
public class summonSevNum
{
public static void main(String[] args) throws Exception
{
Scanner scan = new Scanner( System.in );
int total= 0;
System.out.print( "Which file would you like to read numbers from: " );
String moniker = scan.next();
System.out.println( "Reading numbers from \"" + moniker + "\"" );
Scanner inFile = new Scanner( new File(moniker));
while ( inFile.hasNextInt() )
{
int num = inFile.nextInt();
System.out.print( num + " " );
total = total + num;
}
System.out.println();
System.out.println( "Total is " + total);
}
}