This website is preserved for historical and scholarly reference and is no longer actively maintained.
QUIZ 31
November 5, 1997
Given the Java statement:
int [ ] grades = { 11, 4, 9, ... };
write a segment of Java code that will find the average of the grades in the array.
The sum of the grades should be type int, but the average should be type double. Be careful to cast the sum as a double before dividing.
Also, test for denominator zero before dividing. (Do not divide by zero.)
Use grades.length to determine the number of entries actually in the array.