import java.util.*; import java.io.*; class ReadNumbers{ private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) ); public static void main(String[] args) { // read until no more numbers while(true) { // Prompt the user System.out.println( "Type a number you want to insert. " ); System.out.print( "The number should be in the range 1..1000: " ); try{ // Read a line of text from the user. String input = stdin.readLine(); // converts a String into an int value int number = Integer.parseInt( input ); if((number <= 0) || (number > 1000)) break; System.out.println("You typed " + number); } catch(java.io.IOException e) { System.out.println(e); } } // end of while-true } // end of main method } // end of class