How to put conditions in loop statements : <p>This program is to take input from the user and to give output back showing how many numbers were above the average of the array and below it. I'm trying to put a condition on the loops to exit getting input.</p>

<pre><code>import java.util.Scanner;
public class analyzeScores {

    public static void count(int[] list) {
        Scanner input = new Scanner(System.in);
        for(int i = 0; i &lt; list.length;i++) {
            if(list[i] != 0)
                list[i] = input.nextInt();

        }
    }


    public static void sorts(int[] lists, int average) {
        int high = 0;
        int low = 0;
        for(int i = 0; i &lt; lists.length; i++) {
            if(lists[i] &gt;= average) {
                high +=1;
            }
            else {
                low += 1;
            }
        }
        System.out.println("The number of higher then average scores    is " + high);
        System.out.println("The number of lower then average scores is " + low);
    }
    public static void main(String[] args) {
        int[] list = new int[10];
        System.out.println("Enter the scores: ");
        count(list);
        int total = 0;
        for (int i = 0; i &lt; list.length;i++) {
            total += list[i];
        }
        total = total / list.length;
        sorts(list, total);
    }
}
</code></pre>

<p>I'm trying to figure out how to implement a way to input 0 to exit the loop in the count(int[] list) method. I tried to implement if(list[i] != 0) but messes the whole code up</p>
