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
Describe what V1-V4 is
photoshop1234 [79]

Answer:

it is wave inversion

Explanation:

8 0
3 years ago
Which statement most accurately describes Pascal's law?
marin [14]

Answer:

La  C

Explanation:

7 0
3 years ago
Read 2 more answers
A binary geothermal power plant uses geothermal water at 160°C as the heat source. The cycle operates on the simple Rankine cycl
bogdanovich [222]

A binary geothermal power operates on the simple Rankine cycle with isobutane as the working fluid. The isentropic efficiency of the turbine, the net power output, and the thermal efficiency of the cycle are to be determined

Assumptions :

1.  Steady operating conditions exist.

2.  Kinetic and potential energy changes are negligible.

Properties:  The specific heat of geothermal water ( c_{geo}[) is taken to be 4.18 kJ/kg.ºC.  

Analysis (a) We need properties of isobutane, we can obtain the properties from EES.

a. Turbine

PP_{3} = 3.25mPa = (3.25*1000) kPa\\= 3250kPa\\from the EES TABLE\\h_{3} = 761.54 kJ/kg\\s_{3} = 2.5457 kJ/kg\\P_{4} = 410kPa\\\\s_{4} = s_{3} \\h_{4s} = 470.40kJ/kg\\\\T_{4} = 179.5^{0} C\\\\h_{4} = 689.74 kJ/KG\\\\ The  isentropic  efficiency, n_{T} = \frac{h_{3}-h_{4}  }{h_{3}- h_{4s} }

==\frac{761.54-689.74}{761.54-670.40} \\=\frac{71.8}{91.14} \\=0.788

b. Pump

h_{1} = h_{f} @ 410kPa = 273.01kJ/kg\\v_{1} = v_{f} @ 410kPa = 0.001842 m^{3}/kgw_{p,in} =  \frac{v_{1}(P_{2}-P_{1})   }{n_{p} } \\\\= \frac{0.01842(3250-410)}{0.9} \\\\ =5.81kJ/kg\\h_{2} =h_{1} + w_{p,in}\\          = 273.01+5.81\\           = 278.82 kJ/kg\\\\w_{T,out} = m^{.}  (h_{3} -h_{4} )\\=(305.6)(761.54-689.74)\\=305.6(71.8)\\=21,942kW\\\\

W^{.} _ {P,in} = m^{.} (h_{2} -h_{1}) \\=m^{.}  w_{p,in \\=305.6(5.81)\\\\=1,777kW\\W^{.}  _{net} = W^{.} _{T, out} - W^{.}  _{P,in} \\= 21,942-1,777\\=20,166 kW\\\\HEAT EXCHANGER\\\\Q_{in} = m^{.} _{geo} c_{geo} (T_{in-T_{out} } )\\=555.9(4.18)(160-90)\\=162.656kW\\

c. The thermal efficiency of the cycle  n_{th}  =\frac{W^{.} _{net} }{Q^{._{in} } } \\\\= \frac{20,166}{162,656} \\=0.124\\=12.4%

7 0
3 years ago
Read 2 more answers
Can you help me with this
Fiesta28 [93]

the function is to provide sealed combustion so that the loss of gas is minimized

6 0
2 years ago
The major resisting force in gravity dam? ​
inna [77]

The self weight of dam.

6 0
3 years ago
Read 2 more answers
Other questions:
  • A motor vehicle has a mass of 1.8 tonnes and its wheelbase is 3 m. The centre of gravity of the vehicle is situated in the centr
    14·1 answer
  • Estimate the daily carbon utilization to remove chlorobenzene from 1.0 MGD of ground water saturated with chlorobenzene. Assume
    12·1 answer
  • A drainage ditch alongside a highway with a 3% grade has a rectangular cross-section of depth 4 ft and width 8 ft, and is fully
    12·1 answer
  • The rolling process is governed by the frictional force between the rollers and the workpiece. The frictional force at the entra
    5·1 answer
  • Item110pointseBook HintPrintReferences Check my work Check My Work button is now disabled5Item 1Item 1 10 pointsAn ideal Diesel
    10·1 answer
  • 1. You are asked to write a report about one of the structures that Transportation Engineers
    9·1 answer
  • Anything you want to do in Hootsuite can be found in the ________, with the main workspace in the _________?
    15·1 answer
  • People learn best in different ways. By combining all the group presentations, your class will explain how they see the optical
    8·2 answers
  • Calculate the resistance of a circuit with 1.5 A and 120 V. Use the appropriate formula from the list of formulas on the
    9·1 answer
  • Technician A says reducing spark advance can cause spark knock. Technician B says excessive carbon deposits can cause spark knoc
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!