Difficult# Min, Max, and Average Calculation of Array Values

APCSA-XDPTN1

Will the following segment of code correctly compute the minimum, maximum and average ACT scores for the class?

```
double min = 99, max = 0, sum = 0;
int[] ACTscores = new int[200];
/* Assume that code exists here to enter the ACT scores for all
* students in a small AP Calculus class and store them in this
* ACTscores array beginning at position 0. The lowest possible
* ACT score is 1 and the highest possible score is 36. The following
* loop is written to determine the minimum, maximum, and average
* ACT scores of this class.
*/
for (int score : ACTscores)
{
if (score < min)
min = score;
if (score > max)
max = score;
sum += score;
}
System.out.println("Minimum ACT score is " + min);
System.out.println("Maximum ACT score is " + max);
System.out.println("Average ACT score is " + sum/ACTscores.length);
```