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
Which of the following are all desirable properties of a hydraulic fluid? a. good heat transfer capability, low viscosity, high
Vinvika [58]

Answer:

e.Fire resistance,Inexpensive,Non-toxic.

Explanation:

Desirable hydraulic property of fluid as follows

1. Good chemical and environment stability

2. Low density

3. Ideal viscosity

4. Fire resistance

5. Better heat dissipation

6. Low flammability

7. Good lubrication capability

8. Low volatility

9. Foam resistance

10. Non-toxic

11. Inexpensive

12. Demulsibility

13. Incompressibility

So our option e is right.

5 0
3 years ago
Machine movement can be divided into what two main categories?
pishuonlain [190]

Answer:

motion and power

Explanation:

8 0
4 years ago
Read 2 more answers
A gas stream contains 4.0 mol % NH3 and its ammonia content is reduced to 0.5 mol % in a packed absorption tower at 293 K and 10
bagirrra123 [75]

Answer:

Explanation:

Step by step solved solution is given in the attached document.

8 0
3 years ago
Two streams of air enter a control volume: stream 1 enters at a rate of 0.05 kg / s at 300 kPa and 380 K, while stream 2 enters
alex41 [277]

Answer:

0.08kg/s

Explanation:

For this problem you must use 2 equations, the first is the continuity equation that indicates that all the mass flows that enter is equal to those that leave the system, there you have the first equation.

The second equation is obtained using the first law of thermodynamics that indicates that all the energies that enter a system are the same that come out, you must take into account the heat flows, work and mass flows of each state, as well as their enthalpies found with the temperature.

 

finally you use the two previous equations to make a system and find the mass flows

I attached procedure

5 0
3 years ago
Which of the following Identifies the challenges faced by scientists experimenting with using artificial photosynthesis as
bezimeni [28]

Answer:

The cost and size of materials needed to produce energy

Explanation:

Artificial photosynthesis is a chemical process that uses solar cells instead of chlorophyll to absorb sunlight and convert it into electricity. This process uses artificial leaves that require man-made catalyst to spilt water present in the air into hydrogen and oxygen. It is clear that the reaction requires heat from the sun for energy production thus the technology is expensive to be applied in most areas of the world. Additionally, results obtained from previous undertaken projects of this type has been ineffective and unsustainable because it involves a lot of trial and error.

8 0
3 years ago
Other questions:
  • A Michelson interferometer operating at a 500 nm wavelength has a 3.73-cm-long glass cell in one arm. To begin, the air is pumpe
    9·1 answer
  • Water circulates throughout a house in a hot water heating system. If the water is pumped at a speed of 0.50m/s through a 4.0-cm
    5·1 answer
  • 5. What are the 3 basic types of electrical circuits?
    12·1 answer
  • The flow curve for a certain metal has parameters: strain-hardening
    8·1 answer
  • if a voltage is applied to a capacitor, current flows easily at first and then slows as the capacitor becomes charged. Inductors
    5·1 answer
  • Which of the following refers to software designed to alter system files and utilities on a victim’s system with the intention o
    15·1 answer
  • (Signal Property) Under what condition is a discrete-time signal x[????] or a continuous-time signal x(????) periodic? Determine
    5·1 answer
  • Describe two other safe driver skills a driver should use when driving in this road condition
    7·1 answer
  • Which option distinguishes why the behaviors of the team in the following scenario are so important during the engineering desig
    5·1 answer
  • If a bearing needs 4. 0 s to solidify enough for impact, how high must the tower be?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!