Answer:

The complete program is given below.

Improved Prompt Program

You could have answered the question by mechanically writing in a statement to increment count, as the documentation suggests. Hopefully you understand the larger context of what is going on. Often in programming, several variables have to be kept coordinated like this. It is a juggling act.

    int count = 0;   // number of integers read in

    // get the first value
    System.out.println( "Enter first integer (enter 0 to quit):" );
    value = scan.nextInt();

    while ( value != 0 )    
    {
      //add value to sum
      sum = sum + value;

      //increment the count
      count = count + 1;

      //get the next value from the user
      System.out.println( "Enter the " + 
          (count+1) + "th integer (enter 0 to quit):" );
      value = scan.nextInt();
    }

    System.out.println( "Sum of the "  + count + " integers: " + sum );
  }
}

Let us work on correcting the grammar in the prompt. We will use nested if-else statements inside the loop body. This will get somewhat complicated.

QUESTION 7:

What suffix goes with each integer? E.g. 1 gets "st" to make 1st.