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
Is an example of an electrical device.
Yuki888 [10]
I think that it is all of the above
5 0
3 years ago
Read 2 more answers
Type the correct answer in the box. Spell all words correctly.
AVprozaik [17]

Answer:

Mechanical engineer? Thats my guess I didnt have alot of options sorry if I am wrong

Explanation:

3 0
3 years ago
if you had 100 B size sheets and you cut them into A size sheets, how many sheets of A size paper would you have
castortr0y [4]

Answer:

200

Explanation:

A size sheets (also known as letter size) are 8.5 inches by 11 inches.

B size sheets (also known as ledger size) are 11 inches by 17 inches.

One B size sheet is twice as large as a A size sheet.  So if you have 100 B size sheets and cut each one in half, you'll get 200 A size sheets.

8 0
3 years ago
Car B is traveling a distance dd ahead of car A. Both cars are traveling at 60 ft/s when the driver of B suddenly applies the br
vagabundo [1.1K]

Answer:

Explanation:

Using the kinematics equation v = v_o + a_ct to determine the velocity of car B.

where;

v_o = initial velocity

a_c = constant deceleration

Assuming the constant deceleration is = -12 ft/s^2

Also, the kinematic equation that relates to the distance with the time is:

S = d + v_ot + \dfrac{1}{2}at^2

Then:

v_B = 60-12t

The distance traveled by car B in the given time (t) is expressed as:

S_B = d + 60 t - \dfrac{1}{2}(12t^2)

For car A, the needed time (t) to come to rest is:

v_A = 60 - 18(t-0.75)

Also, the distance traveled by car A in the given time (t) is expressed as:

S_A = 60  * 0.75 +60(t-0.75) -\dfrac{1}{2}*18*(t-0.750)^2

Relating both velocities:

v_B = v_A

60-12t = 60 - 18(t-0.75)

60-12t =73.5 - 18t

60- 73.5 = - 18t+ 12t

-13.5 =-6t

t = 2.25 s

At t = 2.25s, the required minimum distance can be estimated by equating both distances traveled by both cars

i.e.

S_B = S_A

d + 60 t - \dfrac{1}{2}(12t^2) = 60  * 0.75 +60(t-0.75) -\dfrac{1}{2}*18*(t-0.750)^2

d + 60 (2.25) - \dfrac{1}{2}(12*(2.25)^2) = 60  * 0.75 +60((2.25)-0.75) -\dfrac{1}{2}*18*((2.25)-0.750)^2

d + 104.625 = 114.75

d = 114.75 - 104.625

d = 10.125 ft

3 0
3 years ago
If the slotted arm rotates counterclockwise with a constant angular velocity of thetadot = 2rad/s, determine the magnitudes of t
astraxan [27]

Answer:

Magnitude of velocity=10.67 m/s

Magnitude of acceleration=24.62 ft/s^{2}

Explanation:

The solution of the problem is given in the attachments

3 0
3 years ago
Other questions:
  • What is the stress concentration factor of a shaft in torsion, where D=1.25 in. and d=1 in. and the fillet radius is, r=0.2 in.a
    7·1 answer
  • How many grams of perchloric acid, HClO4, are contained in 37.6 g of 70.5 wt% aqueous perchloric acid? How many grams of water a
    10·1 answer
  • Fixed rate mortgage offer:
    10·1 answer
  • A heat recovery system​ (HRS) is used to conserve heat from the surroundings and supply it to the Mars Rover. The HRS fluid loop
    12·1 answer
  • Which battery produces more volts per cell, maintenance type or maintenance free ?
    6·1 answer
  • ⊂who else is obsessed with the ornail
    9·1 answer
  • Solve for the unknown values in the circuit in figure 3-9, NEED ANSWERS ASAP
    12·1 answer
  • Can someone tell me what car, year, and model this is please
    15·2 answers
  • Scientists use characteristics to compare stars. Match each characteristic on the left with the statement on the right that uses
    15·1 answer
  • A coil consists of 200 turns of copper wire and have a cross-sectional area of 0.8 mmm square.The mean length per turn is 80 cm
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!