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
nikdorinn [45]
4 years ago
10

Create a static method called negToZero, which takes an integer array, and returns a new integer array in which all negative ent

ries in the input array have been changed to zero. The non-negative entries should remain unchanged. Example: theArray:{0,4,-6,-5,3} ==> {0,4,0,0,3} public static int [ ] negToZero (int [ ] theArray) {
Computers and Technology
1 answer:
postnew [5]4 years ago
5 0

Answer:

public static int[] negToZero(int [] theArray){

        int[] newArray = new int[theArray.length];

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

           if(theArray[i]>=0){

               newArray[i]=theArray[i];

           }else{

              newArray[i]=0;

           }

        }

        return newArray;

    }

Explanation:

The function is a block of the statement which performs the special task.

To return the array from the function, you have to define the function with return type array.

like, int[] name(parameter){

}

Then declare the new array with the same size.

Take the for loop for traversing in the array and check the condition for positive numbers by using if-else statement, if the value is positive store in the new array as it is. Otherwise, store the zero in the new array with the same position.

This process repeated until the condition in the for loop is true.

and finally, return the array.

You might be interested in
Dash+dash=100<br>Both dash and dashare prime numbers.<br>How many different solutions can you find​
ioda

Answer:

6

Explanation:

97+3 = 100

89+11 = 100

83+17 = 100

71+29 = 100

59+41 = 100

53+47 = 100

I counted them using excel, see pic.

5 0
3 years ago
Unless you specify otherwise, excel summarizes data by ____.
Lilit [14]
Unless you specify otherwise, excel summarizes data by  summing numeric data and counting data fields containing text.
<span> The most commonly used ways to </span><span>summarize data in excel are: pivot tables, autosum, sort, selection....
</span>
4 0
3 years ago
Fill in the blank. THANK YOUU
Svetllana [295]

Answer:

She's procrastinating

Explanation:

3 0
3 years ago
Why do attackers tend to target public or private Wi-fi networks?<br><br><br> I’ll mark as brainiest
Assoli18 [71]

Answer:

Explanation:

bc they're easier to crack

6 0
3 years ago
Read 2 more answers
Slide rule was the first mechanical calculator. true or false​
drek231 [11]

Answer:

False. Pascal's calculator was the first mechanical calculator invented by Blaise Pascal in the mid 17th century.

7 0
3 years ago
Read 2 more answers
Other questions:
  • The part of the inside of a computer
    14·1 answer
  • If a ≤m b and b is regular, does that imply that a is a regular language? why or why not?
    6·1 answer
  • Three consecutive even integers heve a sum of 66. find the integers
    7·1 answer
  • (A) writer or word <br> (B) Calc or Excel <br> (C) impress or PowerPoint<br> (D) none of these
    14·1 answer
  • Which of the following is the 1's complement of 10?
    10·2 answers
  • The Python print function
    9·1 answer
  • What is the component on the motherboard that confirms all devices are in working order once the computer is turned on?
    13·1 answer
  • Write a MATLAB code for the following problem:
    13·1 answer
  • Complete the rest of this statement:
    13·1 answer
  • Write the pseudocode for a program that will process attendance records of CA students. The students attend college five days a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!