Solved

What Does the Following Loop Compute? Scanner in = New

Question 1

Multiple Choice

What does the following loop compute? Scanner in = new Scanner (System.in) ;
Int sum = 0;
Int count = 0;
While (in.hasNextInt() )
{
Int value = in.nextInt() ;
If (value > 0)
{
Sum += value;
Count++;
}
}
Double result = (sum * 1.0) /count;


A) The average of all the integers in the input
B) The sum of all the positive integers in the input divided by the number of integers in the input
C) The average of all the positive integers in the input
D) The second smallest value in the input

Correct Answer:

verifed

Verified

Related Questions