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
What is a trojan horse in computer science?
Firdavs [7]

Answer:

type of malware that is often disguised as legitimate software. Trojans can be employed by cyber-thieves and hackers trying to gain access to users' systems. Users are typically tricked by some form of social engineering into loading and executing Trojans on their systems.

Explanation its malware

4 0
2 years ago
Write a recursive function to compute sum of first N integers starting with 1.
Citrus2011 [14]

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// recursive function to find sum from 1 to n

int recur_Sum(int n)

{ // base condition

if (n <= 1)

 return n;

// recursive call

return n + recur_Sum(n - 1);

}

// main function

int main()

{

   // variables

   int n;

   cout<<"Enter a number:";

   // read the number

   cin>>n;

   // print the sum

   cout<<"Sum of first "<<n<<" integer from 1 to "<<n<<" is:"<<recur_Sum(n);

return 0;

}

Explanation:

Read a number from user and assign it to variable "n".Call function recur_Sum() with parameter "n".This function will recursively call itself and find the Sum of first n numbers from 1 to n.Then function will return the sum.

Output:

Enter a number:10

Sum of first 10 integer from 1 to 10 is:55

4 0
3 years ago
Q9. Complete the table with the name of the functions
umka21 [38]

Answer:

1. VLOOKUP function.

2. SUMIF function.

3. COUNT function.

4. IF function.

5. HLOOKUP function.

Explanation:

Microsoft Excel is a software application or program designed and developed by Microsoft Inc., for analyzing and visualizing spreadsheet documents. There are different types of functions used in Microsoft Excel to perform specific tasks and these includes;

1. VLOOKUP function: it's an Excel function that avails end users the ability to lookup data in a table organized vertically. Thus, it's typically used for searching values in a column.

2. SUMIF function: it is an Excel function to sum cells that meet criteria such as text, dates and numbers. This function can be used with the following logical operators; <, >, and =.

3. COUNT function: it's an Excel function to find the total number of entries in a column. For example, to count the number of entries in B1:B15; COUNT(B2:B15).

4. IF function: runs a logical test and returns one value for a TRUE result, and another for a FALSE result. For example, to fail scores that are below 40; IF (A1 < 40, "Fail", "Pass").

5. HLOOKUP function: it's an Excel function that avails end users the ability to lookup data in a table organized horizontally. Thus, it's typically used for searching values in a column.

4 0
3 years ago
Review how to write a for loop by choosing the output of this short program.
Natalija [7]

This for loop will output:

0

2

4

The range(3) is all the integers between 0 inclusive and 3 exclusive. 0, 1, 2.

Every iterations through the for loop, we multiply the value of each number by 2 and print it to the console.

0 * 2 = 0

1 * 2 = 2

2 * 2 = 4

I hope this helps.

5 0
3 years ago
Read 2 more answers
Which network device sends data to every device that is connected to it?.
podryga [215]

Answer:

A hub broadcasts all data traffic to all networking devices connected to it's data ports. this is used to interconnect networking devices.

What is Hub?

a device that uses it's ports to connect devices (computer, printers, etc.) together.

5 0
2 years ago
Other questions:
  • A personal computer uses a number of chips mounted on a circuit board called microprocessor. system board. daughter board. mothe
    8·1 answer
  • Which of the following statements is true about scalability? Choose 3 options.
    9·2 answers
  • Do you agree that digital signatures are the best way to protect the data in question?
    13·1 answer
  • The following sentence has a mistake.
    13·1 answer
  • Write a program to compute answers to some basic geometry formulas. The program prompts the user to input a length (in centimete
    7·1 answer
  • What service converts ip addresses into more recognizable alphanumeric names??
    8·1 answer
  • Dotted Decimal Notation was created to______________. Group of answer choices provide an alternative to IP addressing express ea
    12·1 answer
  • Identify the correct sequence of steps to change the font from Verdana to Arial.
    5·1 answer
  • In c please
    7·1 answer
  • Superclass in python explanation
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!