1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MaRussiya [10]
3 years ago
9

Use the arr field and mystery () method below.

Computers and Technology
1 answer:
kolezko [41]3 years ago
7 0

Answer:

The sum of all positive even values in arr

Explanation:

We have an array named arr holding int values

Inside the method mystery:

Two variables s1 and s2 are initialized as 0

A for loop is created iterating through the arr array. Inside the loop:

num is set to the ith position of the arr (num will hold the each value in arr)

Then, we have an if statement that checks if num is greater than 0 (if it is positive number) and if num mod 2 is equal to 0 (if it is an even number). If these conditions are satisfied, num will be added to the s1 (cumulative sum). If num is less than 0 (if it is a negative number), num will be added to the s2 (cumulative sum).

When the loop is done, the value of s1 and s2 is printed.

As you can see, s1 holds the sum of positive even values in the arr

You might be interested in
Create a new Die object. (Refer to Die.html for documentation.)Create a loop that will iterate at least 100 times. In the loop b
hjlf

Answer:

Java code is given below

Explanation:

import java.util.Random;

class Die{

private int sides;

public Die(){

sides = 6;

}

public Die(int s){

sides = s;

}

public int Roll(){

Random r = new Random();

return r.nextInt(6)+1;

}

}

class DieRoll{

public static void main(String[] args) {

Die die = new Die();

int arr[] = new int[6];

for(int i=0; i<6; i++)

arr[i] = 0;

for(int i=0; i<100; i++){

int r = die.Roll();

arr[r-1]++;

}

for(int i=0; i<6; i++)

System.out.println((i+1)+" was rolled "+arr[i]+" times.");

}

}

8 0
3 years ago
How to call a variable as a tag in react native.
Pepsi [2]

Explanation:

There is no need of adding template strings inside a <Text> component for adding strings in react-native. You can just use simple text and for variables, you can wrap it with curly braces

6 0
2 years ago
Which of the following is a sign that a website is inappropriate?
nata0808 [166]

Answer:

A

Explanation:

If you find something embarrassing, its more likely that other people with also think its embarrassing. All the other points are on the internet right now. Amazon sells things, News show information and there are political campaigns to show you there offers

3 0
3 years ago
Read 2 more answers
Jacob is preparing a presentation on the health and social advantages of taking up a sport at an early age. Most of the slides i
NARA [144]

Answer:

It's C

Explanation:

On edgenuity

4 0
3 years ago
Which of the following are true about the PUSH instruction?
kkurt [141]

Answer:

Option A.

Explanation:

Only option A satisfies the definition of push statements. So it is only the correct option.

7 0
3 years ago
Other questions:
  • Write statementsto show how finding the length of a character array char [ ] differs from finding the length of a String object
    9·1 answer
  • How do you destroy data on hard drive?
    8·2 answers
  • All of the following activities may infect your computer with a virus EXCEPT ________.
    6·1 answer
  • Tamara has $500 she is looking to save for a class trip. She wants to earn the most possible interest and will not need access t
    7·1 answer
  • What is my favorite color?<br> Red<br>Orange<br>Yellow<br>Blue <br>Gold<br>Silver
    13·1 answer
  • Match the file extensions to the file types. Some file types may be used more than once.
    11·1 answer
  • Which part of a touchscreen responds to pressure applied to its surface?
    6·1 answer
  • Which view in the View tab of the ribbon is the easiest place to add a header or a footer? Normal view Custom Views Page Layout
    5·2 answers
  • Write a method for the Invitation class that accepts a parameter and uses it to update the address for the event.
    9·1 answer
  • How many accelerometers are there in an IRS system?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!