I have a problem with my code.Please help me to solve it. Program should quit and return average when q is entered. If you enter 5 numbers it is working fine. The array size should be 20. Here is the code:

```
import java.util.Scanner;

public class test{

public static void main(String[] args){

int x;

int count=0;
char q= 'q'; 
Scanner input = new Scanner(System.in);
int[] array = new int[5];
System.out.print("You have entered 0 numbers, please enter a number or q to quit:" );

while (input.hasNextInt()){

for (int i = 0; i < array.length; i++)
{

    array[i] = input.next();

    count++;
    System.out.print("You have entered " +count+ " numbers, please enter a number or q to quit:" );
    }
}

System.out.println("Average is " + Average(array));
}

public static int Average(int[] array) {
int sum = 0;
for (int i = 0; i < array.length; i++)
sum += array[i];
return sum / array.length;
}

}

```