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
zhuklara [117]
3 years ago
10

Write a static method reOrder56(int[] nums) that return an array that contains exactly the same numbers as the given array, but

has been reorderd so that every 5 is immediately followed by a 6. You may choose to move every other number with the exception of 5; You are not to move 5. The array contains the same number of 5's and 6's, every 5 has a number after it that is not a 5, and a 6 appears in the array before any 6.
Computers and Technology
1 answer:
denpristay [2]3 years ago
8 0

Answer:

Follows are the code to the given question:

static int[] reOrder56(int[] nums)//defining a static method reOrder56 that holds an array in parameter

{

   int x,y;//defining integer variables

   for(x=0;x<nums.length;x++)//using for loop that counts array  

   {

       if(nums[x]==5 && nums[x+1]!=6) //defining if block checks arry values

       {

           for(y=0;y<nums.length;y++)//use for loop to count array value again  

           {

               if(nums[y]==6 && nums[y-1]!=5)//defining if block checks arry values  

               {

                   nums[y] = nums[x+1];//swap the array element value

                   nums[x+1] = 6;//holing value in array

                   break;//break the condition

               }

           }

       }

   }

}

Explanation:

In this code, a static method "reOrder56" is declared that takes an integer array "nums" in its parameter, and inside the method, two integer variable "x, y" is defined, which is used in the nested loop.

In the first loop, it holds array values and uses the if block to check the array element value and define another loop to check the same condition, and this block, swap the value and holds the value in the array and breaks the condition.

You might be interested in
In 3–5 sentences, describe how technology helps business professionals to be more efficient.
quester [9]

Answer:

Technology helps business professionals, keep more organized, communicate better, and effectively keeps businesses secure. Technology helps keep employee information and business paper work more organized using computers and software; while making it easier to communicate with employee's using e-mail and memo's.

Explanation:

8 0
3 years ago
Read 2 more answers
let's imagine you're searching for hotels in searching chicago, what should you search for in order to get the most relevant res
n200080 [17]

Trivago, Trip advisor,

3 0
3 years ago
Which is an example of the operation of a game?
SVEN [57.7K]

Answer:

D.  

The player uses a joystick to control the character.

Explanation:

The MEANING of operation is: "The fact or condition of functioning or being active."

This explains that the answer is D because you are using the joystick to control the character. Hope the helps.

6 0
3 years ago
Read 2 more answers
You can increase your efficiency by using your e-mail program's spell checker because it eliminates the need for you to proofrea
galina1969 [7]
The answer is True bc it saves you time and is efficient
6 0
3 years ago
Which of the following is not true about a list of lists
Thepotemich [5.8K]

Answer:

Where's the list??

3 0
3 years ago
Other questions:
  • The EPA requires the use of precise forms called ?
    14·1 answer
  • Write a complete program that declares an integer variable, reads a value from the keyboard into that variable, and writes to st
    11·1 answer
  • Two functions of the UPS​
    8·2 answers
  • The objectivity of a site relates to its a. Appearance c. Graphics b. Biases d. Quotes from other Internet authors
    8·2 answers
  • The multitasking, multi-user, operating system developed by Bell Laboratories that operates on a wide variety of computing platf
    13·1 answer
  • The M:N relationship between STUDENT and CLASS must be divided into two 1:M relationships through the use of the ENROLL entity;
    10·2 answers
  • A technician has been asked to upgrade a processor and needs to do some research. The computer is just a couple of years old. Wh
    13·1 answer
  • Write a Python3 program to check if 3 user entered points on the coordinate plane creates a triangle or not. Your program needs
    12·1 answer
  • Which of the following is not a language commonly used for web programming?
    8·2 answers
  • What are some ways you can use the Effect Options dialog box to customize animations in a presentation? Check all
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!