Question: What does the following loop compute? Scanner in = new Scanner ( System . in ) ; int sum = 0 ; int count =

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;
Question 3 options:
the average of all the integers in the input
the sum of all the positive integers in the input divided by the number of integers in the input
the average of all the positive integers in the input
the second smallest value in the input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!