Asignment: #124 Summing Three Numbers
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: Summing3Numbers
/// File Name: Summing3Numbers.java
/// Date Finished: 5/25/2016
import java.io.File;
import java.util.Scanner;
public class Summing3Numbers {
public static void main(String[] args) throws Exception
{
int a, b, c, sum;
String fileName = "3num.txt";
Scanner keyboard = new Scanner(System.in);
System.out.print("Reading numbers from file \"" + fileName + "\":\n\n>");
Scanner fileIn = new Scanner(new File(fileName));
a = fileIn.nextInt();
b = fileIn.nextInt();
c = fileIn.nextInt();
fileIn.close();
System.out.println("done.");
sum = a + b + c;
System.out.println(a + " + " + b + " + " + c + " = " + sum);
}
}
Picture of the output