Shouldnt really do it like that because he should be dealing with ints and ints cannot be dereferenced with the .length method. I have changed your program a little bit to get you started. Instead of exiting on null input, i have used 0 to exit. You should be able to see why it is best to use ints.
CODE
import java.util.Scanner;
public class Average{
public static void main(String[] args) {
int number = 0;
int sum = 0;
int count = 0;
System.out.println("This program will average a series of numbers.");
Scanner keybd = new Scanner(System.in);
do
{
System.out.println("Enter an integer (or 0 to stop): ");
number = keybd.nextInt();
sum=sum+number;
count++;
}
while(number>0);
System.exit(0);
}
}
Now after the while, you still have to work out the average. The int sum now holds the total of all inputs. Count now holds the number of inputs. average = total/number. You should be able to figure it out.