While loops with Sentinels for Java
<p>I am writing the following program using while loops with sentinels.<br>
The problems I am having include:<br>
(1) Discovering how to obtain the "smallest score" entered without the value equaling the sentinel.<br>
(2) Obtain the "largest score" and "smallest score" when only one integer is entered. </p>

<p>Any help will be greatly appreciated. The following is the details of the program:</p>

<pre><code>//Write a program that inputs a series of exam scores as integers.
//The number of scores is not limited.
//Print the number of scores entered and the largest and smallest score entered. 
//Use a sentinel to terminate the input.
    //Input: Series of exam scores as integers.
    //Output: Number of scores entered and the largest and smallest score entered.

import java.util.Scanner;

public class hwk_6_1 {
    public static void main(String [] args) {

        int exam_score;
        int number_of_scores = 0;
        int i;

        Scanner keyboard = new Scanner(System.in);
        System.out.print("Enter exam score or -1 to end: ");
        exam_score = keyboard.nextInt();

        int largest_score = 0;
        int smallest_score = 0;

        while(exam_score != -1) {
            for(i = 0; i &lt; i + exam_score; i++) {
                System.out.print("Enter exam score or -1 to end: ");
                exam_score = keyboard.nextInt();
                number_of_scores = i;

                if(exam_score &gt; largest_score) {
                    largest_score = exam_score;
                }
                if(exam_score &lt; smallest_score) {
                    smallest_score = exam_score;
                }
            }
        }  
        System.out.println("The number of scores entered: " + (number_of_scores + 1) + ".");
        System.out.println("Largest score: " + largest_score + ".");
        System.out.println("Smallest score: " + smallest_score + ".");
    }
}
</code></pre>

<p>Note: we are not supposed to use an 'if' to check for the sentinel, only a while loop; do not use exit or break. Also, we are to be sure to use a sentinel value and two read statements. Code for this program should be similar to the following algorithm: </p>

<pre><code>read data // first data 
while not last data {
    process data
    read data 
}
</code></pre>