What you need is an array of integers to hold the user input once it has been validated (i.e. converted to integers as you are doing with Integer.parseInt), a for loop to populate the array, and inside that for loop another while loop to validate the input and not move on to the next input until a valid input is received. Your average calculation at the end then needs to sum all the integers in the array and divide by the number of digits.