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
charle [14.2K]
3 years ago
12

A function defined beginning with void SetNegativesToZeros(int userValues[], ... should modify userValues such that any negative

integers are replaced by zeros. The function _____.
Computers and Technology
1 answer:
Stels [109]3 years ago
3 0

Answer:

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

       for(int i=0; i<userValues.length; i++){

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

Explanation:

Using Java programming Language, the method is created to receive an array of ints as parameter (as specified in the question)

Using a for loop, we iterate over the entire array checking for values that are negative (<0) and setting them to zero.

See a complete program below

import java.util.Arrays;

import java.util.Scanner;

public class num1 {

   public static void main(String[] args) {

   // Create an array and assign values

       int [] arr = {1,2,3,-1,1,2,-4};

   //Calling the method setNegativesToZero

   setNegativesToZero(arr);

   }

//Creating the Method

   public static void setNegativesToZero(int userValues[]){

       System.out.println("Array before setting negatives to zero "+Arrays.toString(userValues));

       for(int i=0; i<userValues.length; i++){

           if(userValues[i]< 1){

               userValues[i] = 0;

           }

       }

       System.out.println();

       System.out.println("Array After setting negatives to zero "+Arrays.toString(userValues));

   }

}

You might be interested in
Your principal has hired you to design a drone that can monitor students in the hallways. Before you brainstorm design ideas, yo
torisob [31]
It’s gonna be Answer B because all the other answers just sound silly
8 0
3 years ago
Read 2 more answers
What is the purpose of an arraignment?
IgorC [24]

Answer:

At an arraignment, the court officially illuminates a litigant regarding charges contained in a prosecution or data, gives the respondent a duplicate of the charging instrument, and takes the litigant's response to those charges as a request.

Explanation:

5 0
3 years ago
Read 2 more answers
Select all that apply.
Leto [7]
You may do all of the given options.
Thank You!
8 0
3 years ago
The feature that moves text from the right edge of a paragraph to the beginning of the next line as necessary to fit within the
gregori [183]

Answer:

Return Key (Enter Key on Windows)

Explanation:

It is a key on the keyboard that has a downward arrow with corner leftward, it can be used to start a new line of writing.

6 0
3 years ago
Most search engines provide specific pages on which you can search for____ and
vazorg [7]

Answer: c

Explanation: a

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which social network site has 1.5 billion actives users per month?
    15·1 answer
  • Given a String variable response that has already been declared, write some code that repeatedly reads a value from standard inp
    10·1 answer
  • A message M is encapsulated by the TCP, IP and Ethernet protocols in that order as it travels down a protocol stack. What does t
    5·1 answer
  • Which is technologically backward country? Options United States U K CHILE INDIA
    14·1 answer
  • Read the argument below and determine the underlying principle that was used to come to the conclusion presented: It is recommen
    5·1 answer
  • What is the full form of 'Rom<br>​
    7·2 answers
  • Create a paper of at least 1,800 words describing the situation you selected and explaining the logic that would support an arra
    15·1 answer
  • Two Windows features are “boot in safe mode” (with limited user abilities) and “boot from disk.” Windows also has a third, easy-
    13·1 answer
  • Write a boolean expression that is true if s references the string end.
    8·1 answer
  • Mechanisms that can be used to rescue accident victims
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!