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
P9.28 A large vacuum tank, held at 60 kPa absolute, sucks sea- level standard air through a converging nozzle whose throat diame
eimsori [14]

Answer:

a)  m=0.17kg/s

b)  Ma=0.89

Explanation:

From the question we are told that:

Pressure P=60kPa

Diameter d=3cm

Generally at sea level

T_0=288k\\\\\rho_0=1.225kg/m^3\\\\P_0=101350Pa\\\\r=1.4

Generally the Power series equation for Mach number is mathematically given by

\frac{p_0}{p}=(1+\frac{r-1}{2}Ma^2)^{\frac{r}{r-1}}

\frac{101350}{60*10^3}=(1+\frac{1.4-1}{2}Ma^2)^{\frac{1.4}{1.4-1}}

Ma=0.89

Therefore

Mass flow rate

\frac{\rho_0}{\rho}=(1+\frac{1.4-1}{2}(0.89)^2)^{\frac{1.4}{1.4-1}}

\frac{1.225}{\rho}=(1+\frac{1.4-1}{2}(0.89)^2)^{\frac{1.4}{1.4-1}}

\rho=0.848kg/m^3

Generally the equation for Velocity at throat is mathematically given by

V=Ma(r*T_0\sqrt{T_e})

Where

T_e=\frac{P_e}{R\rho}\\\\T_e=\frac{60*10^6}{288*0.842\rho}

T_e=248

Therefore

V=0.89(1.4*288\sqrt{248})\\\\V=284

Generally the equation for Mass flow rate is mathematically given by

m=\rho*A*V

m=0.84*\frac{\pi}{4}*3*10^{-2}*284

m=0.17kg/s

6 0
2 years ago
There is a dispute between the multiple parties storing financial transaction data on a blockchain over the validity of a transa
spayn [35]

Answer:

dgjkkkkkkkfdcvv

Explanation:

hjklllgfddsssssyjjjkkkk

p.s sorry

5 0
2 years ago
Short-term memoryA) has a larger storage capacity than long-term memory.B) takes longer to retrieve than long-term memory.C) inv
zaharov [31]

Answer:D

Explanation:

Take longer time to retrieve than long term memory, involves transient modifications in the function of pre existing synapses, such as channel modifications.

6 0
3 years ago
14. The top plate of the bearing partition
aliina [53]

Answer:

d. is applied after the ceiling joists are

installed.

7 0
3 years ago
Calculate the rate at which body heat is conducted through the clothing of a skier in a steady- state process, given the followi
olga2289 [7]

Answer:

230.4W

Explanation:

Heat transfer by conduction consists of the transport of energy in the form of heat through solids, in this case a jacket.

the equation is as follows

Q=\frac{KA(T2-T1)}{L} \\

Where

Q=heat

k=conductivity=0.04

A=Area=1.8m^2

T2=33C

T1=1C

L=thickness=1cm=0.01mQ=\frac{(0.04)(1.8m^2)(33-1)}{0.01m}

Q=230.4W

the skier loses heat at the rate of 230.4W

4 0
3 years ago
Other questions:
  • Consider a Mach 4.5 airflow at a pressure of 1.25 atm. We want to slow this flow to a subsonic speed through a system of shock w
    15·1 answer
  • What is the capacity of the machine in batches?
    10·1 answer
  • A converging - diverging frictionless nozzle is used to accelerate an airstream emanating from a large chamber. The nozzle has a
    15·2 answers
  • What are the 2 reasons an alignment should be done?
    13·1 answer
  • Which of the following is part of the highway
    11·2 answers
  • Name the four ways in which heat is transferred from a diesel engine
    7·1 answer
  • Why are there few effective HCI standards?
    6·1 answer
  • What is the process pf distributing and selling clean fuel?​
    6·1 answer
  • Identify three questions a patient might ask of the nuclear medicine technologist performing a nuclear medicine exam.
    11·1 answer
  • Question 2
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!