//Find the sum and average
for (int i = 0; i < numbers.length; i++){
sum += numbers[i];
int average = sum / TOTAL_NUMBERS;
}
Here you are making the average an integer, when in reality it should be a float so that you have the correct precision.
you can either:
a) change "int average = sum / TOTAL_NUMBERS;" to "float average = sum / TOTAL_NUMBERS;"
b) if you really want average to be rounded to an int, type cast the right side of the equals. "int average = (int) sum/TOTAL_NUMBERS;"
so what you should really have looks like this:
for(int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
float average = sum / TOTAL_NUMBERS;
JamesCherrill:... and put line 5 outside the loop!
cant believe i let that slip. thanks james