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
1.
aliya0001 [1]
#1 is D #2 is B #3 is A #4 is D #5 is B
3 0
3 years ago
Read 2 more answers
Edhesive 7.2 code practice Write a function named ilovepython that prints out I love Python three times. Then, call that functio
Marysya12 [62]

Answer:

def i_love_python():

   for _ in range(3):

       print("I love Python")

i_love_python()

Explanation:

3 0
2 years ago
How can anger cause workplace accidents?
Umnica [9.8K]
I think the corect answer is c
8 0
3 years ago
Read 2 more answers
Who can pick up GPS signals
bazaltina [42]

Devices such as TomTom GPS and Garmin GPS pick up a GPS signal


I hope that's help !

5 0
3 years ago
7.3 A hydraulic lift has a mechanical advantage of 6. If the load weighs 780 N, calculate
Zielflug [23.3K]

Answer:

Effort = 120 Newton

Explanation:

Given the following data;

Mechanical advantage = 6

Load = 780 N

To find the effort required to lift the weight;

Mechanical advantage can be defined as the ratio of the load (weight) lifted by a simple machine to the effort (force) applied.

Mathematically, the mechanical advantage is given by the formula;

M.A = \frac {Load}{Effort}

Making effort the subject of formula;

Effort = \frac {Load}{M.A}

Substituting into the formula, we have;

Effort = \frac {720}{6}

Effort = 120 Newton.

3 0
3 years ago
Other questions:
  • The fractional_part function divides the numerator by the denominator, and returns just the fractional part (a number between 0
    8·1 answer
  • What is pressure?
    7·2 answers
  • Lucinda works at a recycling center. She noticed an increase in glass recyclables entering the center. She collects data regardi
    7·2 answers
  • A palindrome number is a number that remains the same when its digits are reversed. Like 16461, for example, is a palindrome num
    13·1 answer
  • Which of the following are actions a programmer could take when debugging a segment of code that would most likely lead to findi
    13·1 answer
  • Which domain indicates that a website is sponsored by a university or college?
    12·1 answer
  • Which type of app is the best choice when it is critical to be able to use the device's features but performance is not critical
    5·1 answer
  • I really want to know the best way to deal as much heart as possible plz tell me
    7·2 answers
  • Write an alogrithm to display the first ten even numbers​
    6·1 answer
  • A computer on a network that is not the server​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!