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
Can someone explain to me how to do circuit calculations
GenaCL600 [577]

Use the following rules:

- The sum of currents that enter and exit a node (junction) is always zero. So if you have 3 wires that connect, through one flows 2A, the other 3A, then the third must deliver 5A (taking the direction into account!)


- The sum of voltages across different components should always add up. So if you have a battery of 10V with two unknown resistors, and over one of the resistors is 4V, you know the other one has the remaining 6V.


- With resistors, V=I*R must hold.

With these basic rules you should get a long way!

7 0
3 years ago
3. Rajat wants to assign green colour to a paragraph. Write the code that will help him in completing the task
coldgirl [10]

Explanation:

use the style attribute

4 0
2 years ago
Question 15 of 25
GaryK [48]
It gains purchasing power. Less money in circulation = more value.
5 0
3 years ago
4. How do artistic designing and engineering designing differ? How do they overlap?
zhannawk [14.2K]

Answer: design is art, art is design.

Any good artist is designing their work. Any good designer has an art to their work. The artist "designs" the composition of any piece they create, be it a painting, sculpture, furniture, etc. There is design even in a child's drawing.

Explanation:

6 0
3 years ago
A file that is 242 megabytes is being downloaded. if the download is 15.4% complete, how many megabytes have been downloaded? ro
Lunna [17]
37.26 megabytes have been downloaded
5 0
3 years ago
Other questions:
  • Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targe
    9·1 answer
  • // This pseudocode is intended to display // employee net pay values. All employees have a standard // $45 deduction from their
    12·1 answer
  • What is one advantage of top-down programming design?
    13·2 answers
  • What item on a business card is generally the most prominent?
    10·2 answers
  • Create a derived class called Car that inherits from Vehicle. The constructor should call the base class constructor, with 4 for
    13·1 answer
  • Data is best described as
    10·2 answers
  • A game developer is purchasing a computing device to develop a game and recognizes the game engine software will require a devic
    7·1 answer
  • Working with text in presentation programs is very ____ using text in other applications.
    10·1 answer
  • DERECTIONS: Identify all the computer software that you need for the following entrepreneurial activities. Refer your answer fro
    5·1 answer
  • A manager suspects that one of his team members has been fraudulently accessing confidential and sensitive information and breac
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!