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
What is pollution?
Aloiza [94]

Answer:

I think its a...if im wrong im so sorry!

3 0
3 years ago
Read 2 more answers
1.
podryga [215]
1. false
2. true
3. true
4. false
5. true 

if you'd like me to elaborate, let me know.
7 0
4 years ago
Create a dictionary named letter_counts that contains each letter and the number of times it occurs in string1. Challenge: Lette
Amanda [17]

Answer:

  1. letter_counts = {}
  2. string1 = "I have a dream"
  3. string1 = string1.lower()
  4. for x in string1:
  5.    if(x == " "):
  6.        continue  
  7.    if x not in letter_counts:
  8.        letter_counts[x] = 1
  9.    else:
  10.        letter_counts[x] += 1
  11. print(letter_counts)

Explanation:

The solution is written in Python 3.

Firstly create a letter_count dictionary (Line 1)

Next, create a sample string and assign it to string1 variable and convert all the characters to lowercase using lower method (Line 4).

Create a for loop to traverse through each character in string1 and check if the current character is a single space, just skip to the next iteration (Line 7 -8). If the current character is not found in letter_counts dictionary, set the initial count value 1 to x property of letter_counts. Otherwise increment the x property value by one (Line 9 -12).

After completion of loop, print the letter_count dictionary. We shall get the sample output {'i': 1, 'h': 1, 'a': 3, 'v': 1, 'e': 2, 'd': 1, 'r': 1, 'm': 1}

4 0
3 years ago
relational integrity constraints are rules that enforce basic and fundamental information-based constraints. True or False
finlep [7]
The answer is true.  Good luck!
8 0
4 years ago
An attribute whose value uniquely identifies an object is called a(n) _______.​
Juliette [100K]
This is called a key attribute!

There are different types of key attributes!

Primary key is the key that is actually chosen, for example a social security number. 

There is also a unique key, say our finger prints! they also uniquely identify humans, but usually we prefer to use social security number when we list people (a unique key could be a primary key if we chose so)

We could also identify people by their social security number and a name, but this is unnecessary, as social security number already gives a full identification. Such a reduntant key is called super key. 
6 0
3 years ago
Other questions:
  • Which of the following refers to a feature of wikis that allows the restoring of earlier work in the event of a posting error, i
    9·1 answer
  • Carrie works on a help desk and is assigned a ticket that was automatically generated by a server because of an error. The error
    14·2 answers
  • Design a full adder circuit using NAND gates only (input : A, B, Cin and output = S, Cout).
    5·1 answer
  • PLEASE HELP!!!!!!!!!!! The Excel tool that extends the height of a selected cell so that all the text fits into the cell and is
    10·2 answers
  • In PowerPoint online what can you add to your presentation from the insert tab
    8·2 answers
  • I need a utube name for a gaming channel....PLEASE HELP...BRAINLIEST
    5·1 answer
  • You are going to create an Arduino sketch where you have two push buttons, one piezo, one
    10·1 answer
  • List three features of the third generation of computers
    13·1 answer
  • The web design teams of a company are working on designing websites for various companies, Pick the ideas that employ proper use
    13·1 answer
  • Multiple Select Which of these are ways a hacker might learn someone's password? Select 3 options. o social engineering keylogge
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!