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
defon
3 years ago
5

Complete the following method named replaceEvens that receives the parameter numbers which is an array of integers. The method m

ust replace all elements of numbers that store even values with the negative of that value. That is, if the number 12 is found in a given position of numbers, then the method must replace the 12 with a -12. You can assume that initially all values in the array are integers greater than zero.

Computers and Technology
1 answer:
Taya2010 [7]3 years ago
3 0

Answer:

Following are the method definition to this question:

public class Neg //defining class Neg

{  

public static void replaceEvens(int[] numbers) //defining a method replaceEvens that accepts array

{

int i; //defining integer variable

for(i = 0 ; i < numbers.length; i++) //defining foop to counts number

{

if(numbers[i]%2 == 0) //defining condition to check number is even  

{

numbers[i] = numbers[i] * -1; //multiply the number by -1

}

}

for(i = 0 ; i < numbers.length; i++) // defining loop print array

{

System.out.print(numbers[i] + " "); //print array

}

}    

public static void main(String[] as)//defining main method  

{

   int[] numbers = {12, 10, 18, 5, 2,22}; //defining array numbers and assign value

   System.out.println("Elements of array: "); //print message

   for(int i = 0 ; i < numbers.length ; i++)  //defining loop to print message

   {

   System.out.print(numbers[i] + " "); //print array

   }

  System.out.println("\n After replaceEvens"); //print message

   replaceEvens(numbers); //calling method replaceEvens

  }

}

Output:

please find the attachment.

Explanation:

  • In the given program a static method replaceEvens is declared, in which array numbers pass as the parameter, inside the for method loop is declared, which counts array number in this loop if block is defined, that check-in array there is an even number.
  • In the condition is true it will multiply the number by -1, and output side the loop it will define another loop to print its value.
  • Inside the main method, a number array is declared, that first prints its value then call the method to print its change value.    

You might be interested in
Please help me please i’ll give brainli
DaniilM [7]
Answer: a digital bulletin board
4 0
3 years ago
__________ contain(s) remnants of word processing documents, e-mails, Internet browsing activity, database entries, and almost a
sergey [27]

<u>Swap files </u>contain(s) remnants of word processing documents, e-mails, Internet browsing activity, database entries, and almost any other work that has occurred during past Windows sessions.

Explanation:

I order to simulate extra space an operating system like windows use hard disk space in order to stimulate extra memory.When a computer system is running low with the memory space the swap file swaps a section of RAM onto the hard disk in order to obtain a free memory space.

This Process at times results in  slowing down of the computer  computer considerably.

<u>The combination of RAM and swap files is known as virtual memory.</u>

It is due to the  use of virtual memory that our computer is able to  run more programs than it could run in RAM alone.

4 0
3 years ago
A(n) _____ allows a user to choose specific files to back up, regardless of whether or not the files have been changed.
Anna35 [415]
<span>A selective backup allows a user to choose specific files to back up, regardless of whether or not the files have been changed.</span>
7 0
3 years ago
What is the purpose of a project overview?
andreyandreev [35.5K]

Answer:

option 3 should be the answer is this helps please give the brainliest award.

7 0
2 years ago
Read 2 more answers
The part of the computer that provides access to the Internet is the
andrew11 [14]

Answer:

MODEM

Explanation:

5 0
3 years ago
Other questions:
  • Processing is handled by the computer’s central processing unit (cpu).​ <br> a. True <br> b. False
    6·1 answer
  • Given positive integer num_insects, write a while loop that prints that number doubled up to, but without exceeding 100. Follow
    8·1 answer
  • What do you think about the argument that word processing reduces the quality of writing?
    11·1 answer
  • What are the basic features of Usenet group
    15·1 answer
  • Write a short note on Computer<br>impact on<br> our society?​
    7·2 answers
  • What is a header row?
    8·1 answer
  • 8.7 lesson practice question 1
    13·1 answer
  • Hey Yo, i need some help, Whats 2+2?
    7·2 answers
  • Smart art is considered a​
    14·1 answer
  • Range paramters - for loop<br> question in picture
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!