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
A. Briefly describe the microstructural difference between spheroidite and tempered martensite. Explain why tempered martensite
masha68 [24]

Answer:

Answered below.

Explanation:

A) Both spheroidite & tempered martensite possess sphere - like cementite particles within their microstructure known as a ferrite matrix. However, the difference is that these particles are much larger for spheroidite than tempered.

B) Tempered martensite is much harder and stronger than spheroidite primarily because there is much more ferrite - cementite phase boundary area for its sphere - like cementite particles.

This is because the greater the boundary area, the more the hardness.

4 0
3 years ago
If a steel cable is rated to take 800-lb and the steel has a yield strength of 90,000psi, what is the diameter of the cable?
goldfiish [28.3K]

Answer:

d = 2.69 mm

Explanation:

Assuming the cable is rated with a factor of safety of 1.

The stress on the cable is:

σ = P/A

Where

σ = normal stress

P: load

A: cross section

The section area of a circle is:

A = π/4 * d^2

Then:

σ = 4*P / (π*d^2)

Rearranging:

d^2 = 4*P / (π*σ)

d = \sqrt{4*P / (\pi*\sigma)}

Replacing:

d = \sqrt{4*800 / (\pi*\90000)} = 0.106 inches

0.106 inches = 2.69 mm

5 0
4 years ago
Is the ASUS ROG Strix B450-F Gaming amd ryzen 5 3600 ready?
Ulleksa [173]

Answer:

yep

Explanation:

7 0
3 years ago
Read 2 more answers
A 24-tooth gear has AGMA standard full-depth involute teeth with diametral pitch of 12. Calculate the pitch diameter, circular p
torisob [31]

Answer:

Explanation:

Given:

Tooth Number, N = 24  

Diametral pitch pd = 12

pitch diameter, d = N/pd = 24/12 = 2in

circular pitch, pc = π/pd  = 3.142/12 = 0.2618in

Addendum, a  = 1/pd = 1/12 =0.08333in

Dedendum, b = 1.25/pd = 0.10417in

Tooth thickness, t = 0.5pc = 0,5 * 0.2618  = 0.1309in

Clearance, c = 0.25/pd = 0.25/12 = 0.02083in

5 0
3 years ago
Read 2 more answers
Summarize key
BlackZzzverrR [31]

Answer:

what are is ethiopia cultural ?

7 0
2 years ago
Other questions:
  • The net potential energy EN between two adjacent ions, is sometimes represented by the expression
    13·1 answer
  • What are the challenges posed by strategic information systems, and how should they be addressed?
    10·1 answer
  • A fluid flows steadily through a pipe with a uniform cross sectional area. The density of the fluid decreases to half its initia
    6·1 answer
  • A team member who has been a good worker for many years has recently been doing poor work. You suspect that he may be tired of h
    6·1 answer
  • The mechanical properties of a metal may be improved by incorporating fine particles of its oxide. Given that the moduli of elas
    5·1 answer
  • We need to design a logic circuit for interchanging two logic signals. The system has three inputs I1I1, I2I2, and SS as well as
    11·1 answer
  • can someone please define these three vocabulary words for my stem class i will give brainliest if i can figure out how
    15·1 answer
  • A 5.74 kg rock is thrown upwards with a force of 317 N at a location where the local gravitational acceleration is 9.81 m/s^2. W
    10·1 answer
  • What are the partial products of 2.3 x 2.6
    15·1 answer
  • While, Do...while, and For loops can best be characterized as which of the following?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!