I don't think I fully understand the concept of looping.
Below is what I put into eclipse and the results I get, am I doing something wrong to get the correct results if you could help thanks
/* Working with a sentinel value
Anderson, Franceschi
*/
import java.util.Scanner;
public class EchoUserInput
{
public static void main( String [] args )
{
final int SENTINEL = -1;
int number;
Scanner scan = new Scanner( System.in );
// priming read
System.out.print( "Enter an integer, or -1 to stop > " );
number = scan.nextInt( );
while ( number != SENTINEL )
{
// processing
System.out.println( number );
// update read
System.out.print( "Enter an integer, or -1 to stop > " );
number = scan.nextInt( );
}
System.out.println( "Sentinel value detected. Goodbye" );
}
}
results
Enter an integer, or -1 to stop > 23
Dani