Assignemnt #125 and Summing Any Three Numbers
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Summing Any Three Numbers
///File Name: SummingAnyThreeNumbers
///Date Finished: 3/28/16
import java.util.Scanner;
import java.io.File;
public class SummingAnyThreeNumbers
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner( System.in );
System.out.print("Which file would you like to read numbers from: ");
String fileChoice = keyboard.nextLine();
Scanner fileIn = new Scanner(new File(fileChoice));
int a = fileIn.nextInt();
int b = fileIn.nextInt();
int c = fileIn.nextInt();
int sum = a + b + c;
System.out.println("Reading numbers from file \"" + fileChoice + "\"");
System.out.println(" ");
System.out.println(a + " + " + b + " + " + c + " = " + sum);
System.out.println(" ");
}
}
Picture of the output