Computers and Technology

Please Help! Assume that you have an array named items containing 100 integers, and an integer named numItems that represents the number of valid integers currently used in the array. All elements from items[numItems] to items[items. length-1] have values of 0.

The following code is designed to calculate and print the average of the valid array elements:

int sum=0, count;
for (count = 0; count < items. length; count++)
{
statement 1
}
statement 2

Which of the following substitutions for and will cause this code to correctly print the average of the valid array elements in items?

A. Statement 1:
sum += items[count];

Statement 2:
System. out. println((double)sum / count);

B. Statement 1:
sum += items[count];

Statement 2:
System. out. println((double)sum / items. length);

C. Statement 1:
sum += items[count];

Statement 2:
System. out. println((double)sum / numItems);

D. Statement 1:
sum += items[items. length-1];

Statement 2:
System. out. println(sum / 100);

E. Statement 1:
sum += items[items. length-1];

Statement 2:
System. out. println((double)sum / numItems);

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 02:30, chaaaa
People with high self-esteem: accept their strengths and weaknesses. believe that failed experiences are failures of their whole self. feel good about who they are only when they reach total success. need positive external experiences to counteract negative feelings that constantly plague them.
Answers: 1
image
Computers and Technology, 23.06.2019 23:30, yasarhan2
Match the following errors with their definitions. a. #name b. #value c. #ref d. 1. when a formula produces output that is too lengthy to fit in the spreadsheet cell 2. when you enter an invalid cell reference in a formula 3. when you type text in cells that accept numeric data 4. when you type in a cell reference that doesn’t exist
Answers: 1
image
Computers and Technology, 24.06.2019 00:20, talyku843
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
Answers: 2
image
Computers and Technology, 24.06.2019 10:00, RG1971
(, urgent need): how do i change my username
Answers: 1
Do you know the correct answer?
Please Help! Assume that you have an array named items containing 100 integers, and an integer name...

Questions in other subjects: