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
Maurinko [17]
3 years ago
12

Write a method with the header public static void swapAdjacent(int[] values) that takes a reference to an array of integers valu

es and swaps adjacent pairs of elements: values[0] with values[1], values[2] with values[3], etc. For example, if you add the following test code to your main method: int[] a1 = {0, 2, 4, 6, 8, 10}; swapAdjacent(a1); System.out.println(Arrays.toString(a1));
Computers and Technology
1 answer:
andreev551 [17]3 years ago
3 0

Answer:

public static void swapPairs(int[] a){

   int len=a.length;

       if(len%2 ==0){

           for(int i=0; i<len; i=i+2){

               a[i]=a[i+1];

               a[i+1]=a[i];

               int[] b={a[i]+a[i+1]};

           }    

       }

       if(len%2 !=0){

           for(int j=0; j<len; j=j+2){

               a[j]=a[j+1];

               a[j+1]=a[j];

               a[len-1]=a[len-1];

               int[] b={a[j]+a[j+1]+a[len-1]};

           }

       }    

}

public static void printArray(int[] a){

   System.out.println(a);

}

You might be interested in
Your boss in the human resources department asks you to write a function that calculates the length of time that employees have
Tems11 [23]

Answer:

Option D is correct i.e., =DATEDIF(C2, $AE$2, "y").

Explanation:

The user's supervisor well into the following department tells him to compose the feature which measures the amount that times staff has served in their company utilizing the DATEDIF feature. Consider whether C2 includes the hiring dates for that staff and then that cell $AE$2 includes the cut-off point for whom to evaluate the hiring time with the duration of the service.

So, therefore the following option is correct according to the given scenario.

4 0
3 years ago
To insert a new slide, which tab option should you select?
jek_recluse [69]

Ithink that the answer is C)

4 0
3 years ago
Read 2 more answers
Why are variables useful in programming?
levacccp [35]
Variables can be useful because they hold a certain number/data value that can easily be accessed and changed. For example, in a game, a players score is a variable that changes as the player gets more points; ie coins, items, etc.

4 0
3 years ago
Read 2 more answers
can someone tell me what to do i’m kinda stuck and don’t know what he’s telling me to do pls ill give brainlist and points
Alexandra [31]

Answer:

Well a debtor is basically someone owing someone money, basically someone in debt. He’s telling cup head boy to take care of the people who owe him or someone else their or his money. Thats basically it.

8 0
2 years ago
Write a brief explanation of the problems that can occur in each of the following scenarios and what you should do to avoid thes
photoshop1234 [79]
1. Horsing around can lead to breaking equipment in the classroom or somebody getting hurt

2. leaving your backpack on the floor can cause someone to fall

3.something unexpected may happen and worsen the problem

4. it can corrupt the computer's files and deleted unsaved work.

if you want the sentences to be longer, add some words to them and make the message the same.
4 0
3 years ago
Other questions:
  • The spreadsheet below shows the age, grade level, major, and minor of four students in college. A purple background in the Major
    7·1 answer
  • How can a wiki contribute to an academic paper?
    9·2 answers
  • Tiffany is an instructor at a college that is run on student tuition and not state taxes. Which statement best describes her emp
    6·2 answers
  • A disadvantage of using an arithmetic mean to summarize a set of data is that __________.
    13·1 answer
  • Que son los sistemas de control con retroalimentacion
    10·1 answer
  • Select the correct navigational path to mark all teachers who have achieved “excellent” on their evaluations a red background.
    11·2 answers
  • Which tool can be used to increase the space between a bullet point or a number and text?
    11·2 answers
  • An application's certificate indicates the application -
    5·1 answer
  • What is the purpose of a format painter in Word?
    15·2 answers
  • Rewrite the Espresso Counter program to Swap or interchange any two rows of the output. Copy and paste just the interchanged par
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!