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
MrRissso [65]
3 years ago
13

The numbers should be added to the merged array in an alternating pattern: first from list 1, then from list 2, then list 1 agai

n, etc. If a number in one of the arrays already appears in the merged array, then it should be ignored, and the program should alternate to the other list again. For example, if the first list begins 1 2 3 10, and the second begins 3 4 5 8, then the merged list would begin 1 3 2 4 5 10 8.
Engineering
1 answer:
Vinvika [58]3 years ago
4 0

Answer:

According to the complete question, the code below gives the solution to the problem in Java with appropriate comments

Explanation:

import java.util.Scanner;

import java.lang.Math;

class Main {

  public static void main(String[] args) {

      int length = 0;

      boolean lengthCheck = true;

      Scanner scan = new Scanner(System.in);

      while (lengthCheck == true)

      {

          System.out.println("Enter an array length (must be 10 or greater):");

          length = scan.nextInt();

          if (length >= 10)

          {

              lengthCheck = false;

          }

      }

      int[] firstArray = new int[length];

      int[] secondArray = new int[length];

      System.out.print("\nFirst Array: ");

      for (int i = 0; i < length; i++)

      {

          firstArray[i] = (int) (Math.random() * 100) + 1;

          System.out.print(firstArray[i] + " ");

      }

      System.out.print("\n\nSecond Array: ");

      for (int i = 0; i < length; i++)

      {

          secondArray[i] = (int) (Math.random() * 100) + 1;

          System.out.print(secondArray[i] + " ");

      }

      System.out.println("\n");

     

     

/*

* A boolean array of length 100 to track list of number we have already added to merge list

*/

      boolean[] isAdded = new boolean[100];

      int[] merge = new int[(firstArray.length + secondArray.length)];

     

      int j=0;

      for (int i = 0; i < length; i++)

      {

          if(!isAdded[firstArray[i] - 1]) {

              merge[j] = firstArray[i];

              j++;

              isAdded[firstArray[i] - 1] = true;

          }

         

          if(!isAdded[secondArray[i] - 1]) {

              merge[j] = secondArray[i];

              j++;

              isAdded[secondArray[i] - 1] = true;

          }

         

      }

     

      System.out.print("Merged Array: ");

     

      for (int i = 0; i < 2*length && merge[i] != 0; i++)

      {

          System.out.print(merge[i] + " ");

      }

      System.out.println("\n");

     

  }

}

You might be interested in
A ballistic pendulum consists of a 3.60 kg wooden block on the end of a long string. From the pivot point to the center‐of‐mass
Pavel [41]

Answer:

17.799°

Explanation:

When the bullet hits the block at that time the momentum is conserved

So, initial momentum = final momentum

P_i=P_f

So 28\times 10^{-3}\times 210=(3.6+0.028)v_f

v_f=1.6207\ m/sec

Now energy is also conserved

So \frac{1}{2}\times (3.6+0.028)\times 1.6207^2=(3.6+0.028)\times 9.81\times 2.8(1-cos\Theta )

cos\Theta =0.8521So\ \Theta =17.799^{\circ}

3 0
2 years ago
Please help me fast, I don’t have time
Anna71 [15]

Answer: precision

Explanation: Because accuracy is where you keep on getting it right but precision is where you get closer and closer

5 0
3 years ago
Diffrent ways to make a header above a window
Oliga [24]

Answer: double click at the top of the page. Or you can also go to home file and click add heading.

Explanation:

5 0
3 years ago
2.) A fluid moves in a steady manner between two sections in a flow
Talja [164]

Answer:

250\ \text{lbm/min}

625\ \text{ft/min}

Explanation:

A_1 = Area of section 1 = 10\ \text{ft}^2

V_1 = Velocity of water at section 1 = 100 ft/min

v_1 = Specific volume at section 1 = 4\ \text{ft}^3/\text{lbm}

\rho = Density of fluid = 0.2\ \text{lb/ft}^3

A_2 = Area of section 2 = 2\ \text{ft}^2

Mass flow rate is given by

m=\rho A_1V_1=\dfrac{A_1V_1}{v_1}\\\Rightarrow m=\dfrac{10\times 100}{4}\\\Rightarrow m=250\ \text{lbm/min}

The mass flow rate through the pipe is 250\ \text{lbm/min}

As the mass flowing through the pipe is conserved we know that the mass flow rate at section 2 will be the same as section 1

m=\rho A_2V_2\\\Rightarrow V_2=\dfrac{m}{\rho A_2}\\\Rightarrow V_2=\dfrac{250}{0.2\times 2}\\\Rightarrow V_2=625\ \text{ft/min}

The speed at section 2 is 625\ \text{ft/min}.

3 0
3 years ago
The dam cross section is an equilateral triangle, with a side length, L, of 50 m. Its width into the paper, b, is 100 m. The dam
lisabon 2012 [21]

Answer:

Explanation:

In an equilateral trinagle the center of mass is at 1/3 of the height and horizontally centered.

We can consider that the weigth applies a torque of T = W*b/2 on the right corner, being W the weight and b the base of the triangle.

The weigth depends on the size and specific gravity.

W = 1/2 * b * h * L * SG

Then

Teq = 1/2 * b * h * L * SG * b / 2

Teq = 1/4 * b^2 * h * L * SG

The water would apply a torque of elements of pressure integrated over the area and multiplied by the height at which they are apllied:

T1 = \int\limits^h_0 {p(y) * sin(30) * L * (h-y)} \, dy

The term sin(30) is because of the slope of the wall

The pressure of water is:

p(y) = SGw * (h - y)

Then:

T1 = \int\limits^h_0 {SGw * (h-y) * sin(30) * L * (h-y)} \, dy

T1 = \int\limits^h_0 {SGw * sin(30) * L * (h-y)^2} \, dy

T1 = SGw * sin(30) * L * \int\limits^h_0 {(h-y)^2} \, dy

T1 = SGw * sin(30) * L * \int\limits^h_0 {(h-y)^2} \, dy

T1 = SGw * sin(30) * L * \int\limits^h_0 {h^2 - 2*h*y + y^2} \, dy

T1 = SGw * sin(30) * L * (h^2*y - h*y^2 + 1/3*y^3)(evaluated between 0 and h)

T1 = SGw * sin(30) * L * (h^2*h - h*h^2 + 1/3*h^3)

T1 = SGw * sin(30) * L * (h^3 - h^3 + 1/3*h^3)

T1 = 1/3 * SGw * sin(30) * L * h^3

To remain stable the equilibrant torque (Teq) must be of larger magnitude than the water pressure torque (T1)

1/4 * b^2 * h * L * SG > 1/3 * SGw * sin(30) * L * h^3

In an equilateral triangle h = b * cos(30)

1/4 * b^3 * cos(30) * L * SG  > 1/3 * SGw * sin(30) * L * b^3 * (cos(30))^3

SG > SGw * 4/3* sin(30) * (cos(30))^2

SG > 1/2 * SGw

For the dam to hold, it should have a specific gravity of at leas half the specific gravity of water.

This is avergae specific gravity, including holes.

6 0
2 years ago
Other questions:
  • g A plane stress element has components sigma x = 160 MPa, tau xy = 100 MPa (CW). Determine the two values pf sigma y for which
    13·1 answer
  • What material resources and intellectual resources were used in self driving cars?
    15·1 answer
  • The creation of designer drugs is outpacing the ability of society to enact laws to prohibit them. Many of these substances have
    11·1 answer
  • When you see a street with white markings only, what kind of street is it?
    7·1 answer
  • You will be observing laminar-turbulent transition for room temperature (about 20°C) water flowing in a 0.602"" ID pipe (Schedul
    8·1 answer
  • 0 - 1"<br> -20<br> -15<br> -10<br> 5<br> 0 1 2 3<br> 0
    14·1 answer
  • For the system form of the basic laws, the momentum of a system can change as a result of: a. pressure acting on the system. b.
    14·2 answers
  • Users say that the game is interesting to look at but the music gets annoying
    9·1 answer
  • Prelest! Introduction to Engineering and Technology 1 Select the correct answer. What technological invention allowed for the pr
    5·1 answer
  • All of the following are drum brake components mounted to the backing plate, EXCEPT:
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!