A good answer might be:

The finished program is given below.

Complete Program

Here is the finished program:

import java.io.*;
class AddUpFile
{
  public static void main ( String[] args ) throws IOException
  {
    int value;
    int sum = 0; // initialize sum

    String line;
    BufferedReader stdin = new BufferedReader( 
        new InputStreamReader( System.in ) );

    int count = 1; // initialize count
    while ( count <= 100 )
    {
      System.out.println("Enter a number:");
      line   = stdin.readLine();
      value  = Integer.parseInt( line.trim() );
      sum    = sum + value; // add to the sum
      count  = count + 1; // increment count
    }

    System.out.println( "Grand Total: " + sum );
  }
}

If you run this program as is you will have to enter 100 integers. This could be tedious. For testing purposes you can change the "100" to a smaller number.

QUESTION 13:

Say that you do have a file of 100 integers and run the program by doing this:

c:\java AddUpFile < largeData.txt

What will the user see on the monitor?