Assignemnt #125
Code
import java.util.Scanner;
import java.io.File;
public class threeAnyFile
{
public static void main( String[] args ) throws Exception
{
String whichFile;
int a, b, c;
Scanner prompt = new Scanner( System.in );
System.out.print( "Which file would you like to read numbers from: " );
whichFile = prompt.next();
System.out.println( "Reading numbers from file \"3nums2.txt\"" );
System.out.println();
Scanner fileIn = new Scanner( new File(whichFile));
a = fileIn.nextInt();
b = fileIn.nextInt();
c = fileIn.nextInt();
System.out.println( a + " + " + b + " + " + c + " = " + (a + b + c) );
}
}
Picture of the output