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]
4 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]4 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
The in situ moist unit weight of a soil is 17.3 kN/m3 and the moisture content is 16%. The specific gravity of soil solids is 2.
Temka [501]

Answer:

Explanation:

Given that,

Moist content w = 16%

The in situ moist unit weight of the soil : γ(in situ) = 17.3 kN/m³

Specific gravity of the soil

G(s) = 2.72

Minimum dry unit weight of the soil

γd(compacted) = 18.1 kN/m³

Moist content is same as above

w = 16%

Question

how many cubic meters of soil from the excavation site are needed to produce 2000 m³ of compacted fill?

Let determine the in situ dry unit weight γd(in-situ) using the relation

γd(in-situ) = γ(in-situ) / [1 + (w/100)]

γd(in-situ) = 17.3/ [1 + (18/100)]

γd(in-situ) = 17.3 / ( 1 + 0.18)

γd(in-situ) = 17.3 / 1.18

γd(in-situ) = 14.66 kN/m³

To determine the Volume of the soil to be excavated (Vex)

Let the Volume to be excavated = V

We can use the relation

V=V(fill) × γd(compacted) / γd(in situ)

Given that, V(fill) = 2000m³

V(fill) is the volume of the compacted fill

Therefore,

V=V(fill) × γd(compacted) / γd(in situ)

Vex = 2000 × 18.1 / 14.66

Vex = 2469.13 m³

So, the excavated volume of the soil is 2469.13 m³

3 0
4 years ago
What is the multiplicity of the root x = -4?
just olya [345]

Answer:

See explanation

Explanation:

The multiplicity of  a root of a polynomial equation is the number of times the root repeats.

Let x=a be the root of f(x), then;

(x-a)^1=0 has a multiplicity of 1.

(x-a)^2=0 has a multiplicity of 2.

(x-a)^3=0 has a multiplicity of 3.

(x-a)^m=0 has a multiplicity of m, where m is a positive integer.

We were given the root x=-4.

If f(x)=(x+4)(x-6)^3

Then the multiplicity of the root x=-4 is 1.

If  f(x)=(x+4)^4(x-6)^3

Then the multiplicity of the root x=-4 is 4.

Since the polynomial function or equation is not given in the question, we cannot determine the multiplicity of this root.

But I hope with this explanation, you can refer to the original(complete) question and choose the correct answer.

8 0
3 years ago
Two identical billiard balls can move freely on a horizontal table. Ball a has a velocity V0 and hits balls B, which is at rest,
Lyrx [107]

Answer:

Velocity of ball B after impact is 0.6364v_0 and ball A is 0.711v_0

Explanation:

v_0 = Initial velocity of ball A

v_A=v_0\cos45^{\circ}

v_B = Initial velocity of ball B = 0

(v_A)_n' = Final velocity of ball A

v_B' = Final velocity of ball B

e = Coefficient of restitution = 0.8

From the conservation of momentum along the normal we have

mv_A+mv_B=m(v_A)_n'+mv_B'\\\Rightarrow v_0\cos45^{\circ}+0=(v_A)_n'+v_B'\\\Rightarrow (v_A)_n'+v_B'=\dfrac{1}{\sqrt{2}}v_0

Coefficient of restitution is given by

e=\dfrac{v_B'-(v_A)_n'}{v_A-v_B}\\\Rightarrow 0.8=\dfrac{v_B'-(v_A)_n'}{v_0\cos45^{\circ}}\\\Rightarrow v_B'-(v_A)_n'=\dfrac{0.8}{\sqrt{2}}v_0

(v_A)_n'+v_B'=\dfrac{1}{\sqrt{2}}v_0

v_B'-(v_A)_n'=\dfrac{0.8}{\sqrt{2}}v_0

Adding the above two equations we get

2v_B'=\dfrac{1.8}{\sqrt{2}}v_0\\\Rightarrow v_B'=\dfrac{0.9}{\sqrt{2}}v_0

\boldsymbol{\therefore v_B'=0.6364v_0}

(v_A)_n'=\dfrac{1}{\sqrt{2}}v_0-0.6364v_0\\\Rightarrow (v_A)_n'=0.07071v_0

From the conservation of momentum along the plane of contact we have

(v_A)_t'=(v_A)_t=v_0\sin45^{\circ}\\\Rightarrow (v_A)_t'=\dfrac{v_0}{\sqrt{2}}

v_A'=\sqrt{(v_A)_t'^2+(v_A)_n'^2}\\\Rightarrow v_A'=\sqrt{(\dfrac{v_0}{\sqrt{2}})^2+(0.07071v_0)^2}\\\Rightarrow \boldsymbol{v_A'=0.711v_0}

Velocity of ball B after impact is 0.6364v_0 and ball A is 0.711v_0.

5 0
3 years ago
Guess my birthday it’s in September you should be good with it
Paraphin [41]

Answer:

spetember 7th

Explanation:

5 0
3 years ago
Technician A says that applying too much braking force can cause tires to lose traction. Technician B says that ABS systems have
Deffense [45]

Answer:

technically both are correct but tech b is more correct because generally the older the vehicle the worse abs is newer vehicles have abs that no matter how hard you push on the brake peddle the wheels shouldnt lock up

Explanation:

7 0
4 years ago
Other questions:
  • How 2 mak robut??...
    6·2 answers
  • What types of arguments are passed to parameters automatically if no argument is provided in the function cell
    9·1 answer
  • Which of the following are rights that workers have under OSHA
    14·2 answers
  • Based on the ELR, the stability classification of the atmosphere at the airport between the surface and 3000 m is
    15·1 answer
  • Horizontal wind turbines have same design for offshore and on shore wind farms. a)-True b)- False
    5·1 answer
  • Explain why many sustainable fishing and forestry practice depend on the actions of consumers like you.
    13·2 answers
  • What is the most common type of suspensions system used on body over frame vehicles?
    15·1 answer
  • Of the core elements of successful safety and health programs, Management Leadership, Worker Participation, and what else relate
    10·2 answers
  • 2. What is the Function of the Camshaft in an Internal Combustion Engine?
    13·1 answer
  • Cierto laboratorio está probando una nueva vacuna contra el SARS coV 2 y la 1ra fase incluyesolo 8 voluntarios de tal forma que
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!