Intro to Java - determine valid unique numbers This is an assignment for an intro to Java course.  It works with the test case given, but I would like to know if there is anything / a lot of things that should be different or could be better.

Specification:


  Write a Java application that accepts 5 “valid” numbers from the user.
  
  A valid number is between 50 and 100 inclusive.  If the user enters a
  number outside of the valid range, an error message should indicate
  this.  An invalid number is not counted as one of the 5.  The user
  might enter 50 invalid numbers, and the program will keep asking for
  numbers between 50 and 100.
  
  If the user enters a number that they have previously entered, this is
  counted as one of the 5.  A message appears that it is not unique.  A
  unique number is a valid number that has not been entered up to this
  point.  A non-unique number is a valid number that has already been
  entered.
  
  After each valid number  is entered, the count of the unique numbers
  entered so far is printed, and all of the unique numbers are printed
  on a single line.  (see example)
  
  When the user has entered 5 valid numbers, a message appears informing
  the user of how many unique, valid numbers were entered, and the
  unique numbers are printed again.


package partB;

import java.util.Scanner;

public class PartB {

    public static void main(String[] args) {

        int[] validNumber;
        int[] uniqueNumber;
        int input, numberOfUnique = 0;
        boolean validCheck, uniqueCheck;
        validNumber = new int[5];
        uniqueNumber = new int[5];

        Scanner userInput = new Scanner(System.in);

        for (int i = 0; i &lt; validNumber.length; i++) {

            System.out.print("\nEnter an integer: \t");
            input = userInput.nextInt();

            validCheck = isValid(input);

            while (validCheck == false) {
                System.out.print("\nEnter an integer: \t");
                input = userInput.nextInt();
                validCheck = isValid(input);
            }

            if (validCheck == true) {

                uniqueCheck = isUnique(validNumber, input);
                validNumber[i] = input;
                if (uniqueCheck == true) {
                    numberOfUnique++;
                    uniqueNumber[i] = input;
                    System.out.println("Unique so far: \t\t" + numberOfUnique);
                    outputStatements(uniqueNumber);

                } else if (uniqueCheck == false) {
                    System.out.println(input + " is valid, but not unique");
                    System.out.println("Unique so far: \t\t" + numberOfUnique);
                    outputStatements(uniqueNumber);
                }
            }
        }
        System.out.println();
        System.out.println("You entered " + numberOfUnique
                + " unique valid numbers!");
        outputStatements(uniqueNumber);
    }

    public static boolean isValid(int validParameter) {
        boolean result;

        if (validParameter &gt;= 50 &amp;&amp; validParameter &lt;= 100) {
            result = true;
        } else {
            result = false;
            System.out.println("The number " + validParameter
                    + " is out of the valid range.");
        }
        return result;
    }

    public static boolean isUnique(int[] array, int uniqueParamter) {
        boolean result = true;

        for (int i = 0; i &lt; array.length; i++)
            if (array[i] != 0) {
                if (array[i] == uniqueParamter) {
                    result = false; // is NOT unique
                    break;
                } else {
                    result = true; // is unique

                }
            }
        return result;
    }

    public static void outputStatements(int[] array) {

        for (int i = 0; i &lt; array.length; i++) {
            if (array[i] != 0) {
                System.out.print(array[i] + " ");
            }
        }
        System.out.println();
    }
}
It looks alright, but there are some improvements you can do. First of all, you can still split your program into smaller functions still, which really helps readability. 

Also, something glaring to me is that your functions in "main" are acting as instance variables for the rest of the class, which should not be the case. You should choose where you declare your variables based on the necessity of their scope. If you only use the input int as a store from user input, it should only be declared in the method that gets input from the user.

For instance, you could omit the input int from main and declare it locally in the GetInputFromUser method.

In main:

for (int i = 0; i &lt; validNumber.length; i++) {
     GetInputFromUser(validNumber, uniqueNumber);
}


The method:

public static void GetInputFromUser(int[] validNums, int[] uniqueNums) {
     int input = userInput.nextInt()
     while (!isValid(input)) {
          System.out.print("\nEnter an integer: \t");
          input = userInput.nextInt();
     }
     //Code ommitted

}


I didn't really have time to read all of the specifications carefully, but I hope this helped a bit! Also, you may want to declare the int arrays as instance variables to avoid passing them around all the time.