import java.util.Scanner;public class ex710 { private static final int N = 5; private static final int MIN = 10; private static final int MAX = 200; private static int number[] = new int[N]; // This method checks an input number and adds the number to the array number[] if the input is valid. // Returns true if the add is successful. Returns false otherwise. public static boolean successfulAdd( int newNumber, int count ){ // Check the range if( newNumber < MIN || newNumber > MAX ){ System.out.println("Invalid range. Expect something between " + MIN + " and " + MAX + " inclusive."); return false; } // Range is OK. Now check for duplicated numbers. for(int i=0; i<count; i++){ if( number[i] == newNumber){ System.out.println("This number is already seen as number["+i+"]."); return false; } } // Not duplicated. Add the number to the array and return. number[count] = newNumber; return true; } public static void main( String args[] ){ Scanner input = new Scanner( System.in ); int count=0; do { System.out.print("Input number[" + count + "]: "); if( successfulAdd( input.nextInt(), count )) count++; } while(count<N); System.out.print("Done! The numbers are: "); for(int n: number) System.out.print(n + " "); System.out.println(); }}