import java.io.*; import java.util.Scanner; public class File02 { public static void main(String[] args) throws IOException { File myFile = new File("inp2"); // Open file "inp2" Scanner in = new Scanner(myFile); // Make Scanner obj with opened file double x; // Variable to receive a floating point number double sum; // Running sum sum = 0.0; // Initialize ("clear the slate") while ( in.hasNextDouble() ) { x = in.nextDouble(); // Read a floating point number sum = sum + x; // Add to running total } System.out.println("Sum = " + sum); } }