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
Who usually signs a collection letter?
murzikaleks [220]
A collection letter is usually signed by THE OFFICE PROFESSIONAL. 
A collection letter refers to the letter written by a company to a debtor in order to remind him or her about pending debts. The letter is usually written by the office holder  that is responsible for that task. Professionals in the accounting department are often responsible for this.<span />
4 0
3 years ago
Read 2 more answers
_______ _____ is the process of creating usable computer pograms and applications and the theories behind those processes. Quest
stepladder [879]
<span>The correct answer is


C. Computer Science</span>
7 0
3 years ago
Read 2 more answers
What are the 3 symbols that can’t be used when saving a document? (From Microsoft Word 2016) (pls helped me!)
Charra [1.4K]

Answer:

\, /, -

Explanation:

The three symbols are forward slash, backward slash, and the hyphen. These were allowed in previous versions of the MS Word. However, since the MS Word 2016 and a little earlier, these three symbols have been banned. And you will immediately get a message if you use these, to correct, and only then the file will be saved with that new name, and that must not have the forward or backward slash or the hyphen.

6 0
4 years ago
When trying to solve a problem, Bret uses a logical, step-by-step formula called ________.
Alexxx [7]

Answer:

B) An Algorithm

Explanation:

An algorithm is defined as the step-by-step solution to a given problem that follows a logical sequence and which is also finite. In mathematics and computer science, the first step in solving a given problem is writing out the algorithm which will include steps for calculations, decisions, data processing, input/output etc. There are scientific ways of representing algorithms through the use of flowcharts, pseudocodes, data flow diagrams etc.

5 0
3 years ago
The page-replacement policy means that pages are not placed to make more space. A. True B. False
BabaBlast [244]

Answer:

B. False

Explanation:

A page-replacement policy can be defined as a set of algorithm that instructs the operating systems on what memory page is to be swapped, paged out or written to disk in order to allocate more memory as they're required by various active processes during virtual memory management.

Some of the algorithms or techniques used by the operating system for page-replacement policy are;

1. Last In First Out (LIFO).

2. First In First Out (FIFO).

3. Least Recently Used (LRU).

4. Least Frequently Used (LFU).

5. Optimal (OPT or MIN).

Hence, the page-replacement policy means that pages are placed to make more space and to minimize the total number of page that would be missing.

7 0
3 years ago
Other questions:
  • What is the part of the computer system that receives inputs, directs those inputs to the processor, and redirects the processed
    14·1 answer
  • What are possible consequences for cyberbullying?
    11·2 answers
  • Why is it important to use standard english when applying for a job
    13·2 answers
  • A(n) ______ chart is drawn on the same worksheet as the data.
    10·1 answer
  • When you're working with a word processing document and you press the del key, what happens?
    5·1 answer
  • True or False: Assuming that all variables are defined, the following segment of code is invalid. if ( x &gt; 0 )
    10·1 answer
  • 2. What is software conflict?<br>​
    11·1 answer
  • Question Mode Matching Question Match the following description with the appropriate programming language generation. 1GL 1GL dr
    7·1 answer
  • A proposal is also known as a
    14·2 answers
  • Who is better, Tom, Ben, Hank, Angela, or Ginger
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!