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
Im lonnnelllly........................who want to date
blsea [12.9K]
Hey just a word of advice I hope you find someone lovely and someone who’ll enjoy you for you. Don’t look for people on apps like this I made many mistakes and it’s not smart. Have a good day. I get the feeling of loneliness and it sucks
8 0
2 years ago
Annabella was giving a presentation to a group of 20 real estate agents on
podryga [215]

Anticipate questions.

3 0
2 years ago
Read 2 more answers
You load an image file into a numpy array and look at its shape, which is (433, 650). What does this indicate?
Nat2105 [25]

Answer:

option C

Explanation:

The correct answer is option C

the uploaded image shape is ( 433 , 650 )

this shape means that the image is a grayscale image which is 433 pixels high by 650 pixels wide.

a gray scale image is  in white and black color.

433 pixels high by 650 pixel wide means that the image is formed with the combination of 433 vertical dots and 650 horizontal dots.

Resolution of an image can be found out by the  pixels present in the images.

higher the pixel higher is he resolution of the image.

6 0
3 years ago
Which one of the following word processing features saves you the most time when keying a document?
drek231 [11]
C) find and replace which finds the words you want to replace in a document and replaces them to whatever you specify
3 0
3 years ago
You are creating a story map about Mexico. After configuring the web app template, you launch the app to test it. When the app o
navik [9.2K]
Nbdjsksjsidjdjwkwejd
3 0
3 years ago
Other questions:
  • In three to five sentences, explain how you would insert graphics using your word-processing software.
    7·2 answers
  • The array s of ints contain integers each of which is between 1 and 1000 (inclusive). write code that stores in the variable ord
    9·1 answer
  • For an machine using 2-dimensional even parity for error detection/correction, and the following received bytes, where is the er
    9·1 answer
  • For which type of long-distance call do you need to tell the operator the name of the person to whom you wish to speak?
    10·1 answer
  • A wireless network does not benefit like a wired network does, when it comes to collision reduction. Which device reduces collis
    6·1 answer
  • Help me plzzzz ASAP T-T and it's Cyber Security but my last day of school is tomorrow and I'll graduate in June 24 so plzzzzz I
    12·1 answer
  • 19 dollar fortnite giftcard who wants it
    15·2 answers
  • Can development and conservation of environment go hand-in-hand? Explain your point of view
    8·1 answer
  • Given two objects represented by the tuples (22, 1, 42, 10) and (20, 0, 36, 8):
    6·1 answer
  • try the following code to see a nullpointer error (if you don’t see the error because of the autograding, you can copy it into t
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!