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:
Verified
Q47: What will be printed by the statements
Q48: Which of the following loops will print
Q49: What will be printed by the statements
Q50: What will be printed by the statements
Q51: What is the output of the code
Q53: How many times does the following loop
Q54: What will be printed by the statements
Q55: What will be printed by the statements
Q56: Which of the following conditions can be
Q57: Which of the following is considered a
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents