Computers and Technology

Use the arr field and mystery () method below. private int[] arr;

//precondition: arr. length > 0
public void mystery()
{
int s1 = 0;
int s2 = 0;

for (int i = 0; i < arr. length; i++)
{
int num = arr[i];

if ((num > 0) && (num % 2 == 0))
{
s1 += num;
}
else if (num < 0)
{
s2 += num;
}
}

System. out. println(s1);
System. out. println(s2);
}
Which of the following best describes the value of s1 output by the method mystery?

The sum of all values greater than 2 in arr
The sum of all values less than 2 in arr
The sum of all positive values in arr
The sum of all positive odd values in arr
The sum of all positive even values in arr

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:30, riah133
Creating "smart interfaces" in all sectors of industry, government, and the public arena is one of the fastest growing hct areas. these interfaces model, interpret, and analyze such human characteristics as speech, gesture, and vision. the field of biometrics, in which humans authenticate themselves to machines, is an area of considerable interest to hct practitioners. fingerprint scans are one of the most frequently used biometric options, and this article, biometric student identification: practical solutions for accountability & security in schools, makes a case for the implementation of fingerprint scans in schools. critique the article, and answer the following questions: according to the author, what are the main benefits of adopting fingerprint scans in schools for student identification? according to the author, what are the main drawbacks of adopting fingerprint scans in schools for student identification? do you agree with the author's assessment of the pl
Answers: 2
image
Computers and Technology, 23.06.2019 05:00, mariahchaparro08
Which best explains why a digital leader would join a society specializing in technology
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, paulusl19
The first screen you see when you open word2016 what is called?
Answers: 1
image
Computers and Technology, 23.06.2019 21:00, kkpsmith
Alcohol’s affects on the cornea and lens of the eye make it more difficult
Answers: 1
Do you know the correct answer?
Use the arr field and mystery () method below. private int[] arr;

//precondition: arr....

Questions in other subjects: