?
Free Version
Easy

# Arithmetic Operations: Calculating Averages

APCSA-PXYDXL

The actual times (in seconds) that it takes several runners to go one mile are stored in an array of integers named times. Your method needs to compute the accurate average time of these runners. Fill in the blanks in the following lines of code to initialize the total and count variables and compute the average.

For example, if the total times are 1005 seconds for 2 runners, then the average time would be 502.5 seconds.

_______ total = 0;   // declare and initialize total
_______ count = 0;   // declare and initialize count

for(int i=0; i< times.length; i++)
{
total+=times[i];
count++;
}
_______ avg = __________;  // compute avg

I.   double total = 0;   int count = 0;  double avg = total/count;
II.  int total = 0;   double count = 0;  int avg = total/count;
III. int total = 0;   int count = 0;  double avg = (double) total/count;
IV.  int total = 0;   int count = 0;  double avg = total/count;

A

I, II, and III only.

B

I, III, and IV only.

C

I and II only.

D

I and III only.

E

I, II, III, and IV.