Programming Assignment #125
Code
import java.util.Scanner;
import java.io.IOException;
import java.io.File;
public class Nums{
public static void main(String[] args){
try{
Scanner k = new Scanner(System.in);
while(true){
System.out.println();
System.out.print("Which file do you want to read from? ");
String file = k.nextLine();
Scanner reader = new Scanner(new File(file));
int a = reader.nextInt();
int b = reader.nextInt();
int c = reader.nextInt();
int sum = a + b + c;
System.out.println();
System.out.println(a + " + " + b + " + " + c + " = " + sum);
System.out.println();
}
}
catch(IOException e){
System.out.println("Crashed.");
}
}
}
Outputs