Solved

What Does the Following Loop Compute? Scanner in = New

Question 52

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

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents