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 computer has been showing signs of a malware infection, and today it started up in Safe Mode. Because your computer is not
son4ous [18]

Answer:

You can log in to the administrator account.

Explanation:

Since your computer is not part of an active domain, you can log in to the admin account, its a built-in account in all Windows OS, this will grant you all privileges, and will allow you to perform any change you want to the computer. It will help you to find and effectively eliminate any malware present in the system.  

3 0
4 years ago
IOS 0R ANDR0ID ???
Lera25 [3.4K]

Answer:

Both are awesome!

Explanation:

One thing we shouldn't do is downgrade others for having an android or calling someone basic because they have ios. Both have their pros and cons, but idk because I don't have a phone! Hehe. But my family primarily uses IOS.

3 0
4 years ago
Need Help ASAP!
jonny [76]

Answer:

Ask about next steps and the best way to communicate.

Send a follow-up email within 24 hours.

Explanation:

3 0
4 years ago
Read 2 more answers
URGENT: I need to add a while loop in this program but I don't know-how. I am also having trouble neatening some lines of code.
dangina [55]

Answer:

Answer is in the provided screenshot.

Explanation:

You are making this more confusing for yourself by doing it like this.

I have added variables at the top of your program for game messages that are repeated - and also simplified the given cases for if the player wins, loses or ties.

I invite you to now make a point tracker that, at the start of each game says: You have "x" points.

And you gain a point for winning, lose a point for losing and nothing happens if you tie.

To add a while loop - simply use the "while" keyword, and anything within the loop will repeat while the given condition is true.

8 0
3 years ago
PLEASE HELP ME ASAP I HAVE AN EXAM SOON!!!!
3241004551 [841]

Answer:

try seeing if the nozzle of the cartridge is clogged

Explanation:

8 0
3 years ago
Other questions:
  • The ________ model allows the owner of a resource to manage who can or cannot access the item. Owners maintain this access throu
    8·1 answer
  • To decrease the size of text so it will fit into a text box without overflowing, select the
    14·2 answers
  • What makes Group Policy such a powerful tool is its ability to enable security administrators to:_________.
    8·1 answer
  • What does the hard disk drive do?
    9·2 answers
  • Material science focuses on<br><br> A) Heat<br> B) Solids<br> C) Liquids<br> D) Gasses
    7·2 answers
  • Which of the following is NOT a name of one of the central features of Facebook? Timeline Activity Log Graph Search Daily News
    11·1 answer
  • Know when the double, int, String, and char data types are best used. Example: I would store a social security number in a strin
    7·1 answer
  • What information is stored in the file system?
    5·1 answer
  • Extend to also calculate and output the number of 1 gallon cans needed to paint the wal. Hint: Use a math function to round up t
    12·1 answer
  • I'm trying the game WWE 2k20 for my computers and technology and a extra credit question is how do you pull down the singlet str
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!