Assignment #125 and Summing Three Numbers from Amy File
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Summing Three Numbers from Any File
/// File Name: AnyThree.java
/// Date Finished: 5/12/2016
import java.io.File;
import java.util.Scanner;
public class AnyThree {
public static void main(String[] args) throws Exception {
Scanner keyboard = new Scanner(System.in);
String choice;
int a, b, c, sum;
System.out.print( "Which file would you like to read numbers from: " );
choice = keyboard.next();
System.out.println("Reading numbers from file \"" + choice + "\".... done.");
Scanner fileIn = new Scanner(new File(choice));
a = fileIn.nextInt();
b = fileIn.nextInt();
c = fileIn.nextInt();
fileIn.close();
sum = a + b + c;
System.out.println(a + " + " + b + " + " + c + " = " + sum);
}
}
Picture of the output