Free Version
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(&quot;Minimum ACT score is " + min);
System.out.println(&quot;Maximum ACT score is " + max);
System.out.println(&quot;Average ACT score is " + sum/ACTscores.length);

A

The minimum, maximum, and average ACT scores will all be incorrect.

B

The minimum score will be correct, but the maximum and average scores will be incorrect.

C

The minimum and maximum scores will be correct, but the average score will be incorrect.

D

The maximum score will be correct, but the minimum and average scores will be incorrect.

E

The minimum, maximum, and average ACT scores will all be correct.