The first integer is prompted for outside of the loop. Inside the loop body, it would be nice to use the following prompts:
Enter the 2nd integer (enter 0 to quit): Enter the 3rd integer (enter 0 to quit): Enter the 4th integer (enter 0 to quit): Enter the 5th integer (enter 0 to quit): Enter the 6th integer (enter 0 to quit): .... and so on .... Enter the 20th integer (enter 0 to quit): Enter the 21th integer (enter 0 to quit):
The prompt shows poor grammar for integers 21, 22, 23, 31, 32, 33 and so on. Let us regard this as acceptable.
The statement to write to the monitor will be changed to this:
System.out.println( "Enter the " +
(count+1) + suffix + " integer (enter 0 to quit):" );
The variable suffix
will be a reference to
one of the Strings: "nd", "rd", or "th".