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
Montano1993 [528]
3 years ago
13

2.4: Add a method called setValue(), and the description of setValue is: public int setValue(long searchKey) In this method, the

array will be examined if searchKey is already in the array. If this is the case, the index of found searchKey in the array will be returned; If searchKey is not in the array, insert it to the array and return the index where it is inserted. Add some code in main() to exercise this method.
Engineering
1 answer:
Yanka [14]3 years ago
6 0

Answer:

Below is java code that must be used for the given question:

// highArray.java

// demonstrates array class with high-level interface

// to run this program: C>java HighArrayApp

////////////////////////////////////////////////////////////////

class HighArray

  {

  private long[] a;                 // ref to array a

  private int nElems;               // number of data items

  //-----------------------------------------------------------

  public HighArray(int max)         // constructor

     {

     a = new long[max];                 // create the array

     nElems = 0;                        // no items yet

     }

  //-----------------------------------------------------------

  public setValue find(long searchKey)

     {                              // find specified value

     int j;

     for(j=0; j<nElems; j++)            // for each element,

        if(a[j] == searchKey)           // found item?

           break;                       // exit loop before end

     if(j == nElems)                    // gone to end?

        return false;                   // yes, can't find it

     else

        return true;                    // no, found it

     }  // end find()

  //-----------------------------------------------------------

  public void insert(long value)    // put element into array

     {

     a[nElems] = value;             // insert it

     nElems++;                      // increment size

     }

  //-----------------------------------------------------------

  public void display()             // displays array contents

     {

     for(int j=0; j<nElems; j++)       // for each element,

        System.out.print(a[j] + " ");  // display it

     System.out.println("");

     }

  //-----------------------------------------------------------

  }  // end class HighArray

////////////////////////////////////////////////////////////////

class HighArrayApp

  {

  public static void main(String[] args)

     {

     int maxSize = 100;            // array size

     HighArray arr;                // reference to array

     arr = new HighArray(maxSize); // create the array

     arr.insert(77);               // insert 10 items

     arr.insert(99);

     arr.insert(44);

     arr.insert(55);

     arr.insert(22);

     arr.insert(88);

     arr.insert(11);

     arr.insert(00);

     arr.insert(66);

     arr.insert(33);

     arr.display();                // display items

     int searchKey = 35;           // search for item

     if( arr.find(searchKey) )

        System.out.println("Found " + searchKey);

     else

        System.out.println("Can't find " + searchKey);

     }  // end main()

  }  // end class HighArrayApp

Explanation:

You might be interested in
What are some quality assurance systems
Aloiza [94]
Examples of quality assurance activities include process checklists, process standards, process documentation and project audit. Examples of quality control activities include inspection, deliverable peer reviews and the software testing process. You may like to read more about the quality assurance vs quality control.
7 0
3 years ago
Two previously undeformed rod-shaped specimens of copper are to be plastically deformed by reducing their cross-sectional areas.
mezya [45]
I am not sure I am stuck on this and I have been for 45 min someone please help me and this girl or boy!!
4 0
3 years ago
Refrigerant-134a enters a 28-cm-diameter pipe steadily at 200 kPa and 20°C with a velocity of 5 m/s. The refrigerant gains heat
Alexandra [31]

Answer:

V = 0.30787 m³/s

m = 2.6963 kg/s

v2 =  0.3705 m³/s

v2 = 6.017 m/s

Explanation:

given data

diameter = 28 cm

steadily =200 kPa

temperature = 20°C

velocity = 5 m/s

solution

we know mass flow rate is

m = ρ A v

floe rate V = Av

m = ρ V

flow rate = V = \frac{m}{\rho}

V = Av = \frac{\pi}{4} * d^2 * v1

V = \frac{\pi}{4} * 0.28^2 * 5

V = 0.30787 m³/s

and

mass flow rate of the refrigerant is

m = ρ A v

m = ρ V

m = \frac{V}{v} = \frac{0.30787}{0.11418}

m = 2.6963 kg/s

and

velocity and volume flow rate at exit

velocity = mass × v

v2 = 2.6963 × 0.13741 = 0.3705 m³/s

and

v2 = A2×v2

v2 = \frac{v2}{A2}

v2 = \frac{0.3705}{\frac{\pi}{4} * 0.28^2}

v2 = 6.017 m/s

7 0
3 years ago
A copper-nickel alloy of composition 60 wt% Ni-40 wt% Cu is slowly heated from a temperature of 1250°C (2280 °F). (a) At what te
makkiz [27]

Answer:

a. The very first liquid process, when heated from 1250 degree Celsius, is expected to form at the temperature by which the vertical line crosses the phase boundary (a -(a + L)) which is about <em>1310 degree Celsius. </em>

b. The structure of that first liquid is identified by the intersection with ((a+ L)-L) phase boundary; <em>47wt %of Ni</em> is of a tie line formed across the (a+ L) phase area <em>at 1310 degrees.</em>

c. To find the alloy's full melting, it is determined that the intersection of the same vertical line at 60 wt percent Ni with (a -(a+L)) phase boundary is around <em>1350 degrees.</em>

c. The structure of the last remaining solid before full melting correlates to the intersection with the phase boundary (a -(a + L), of the tie line built at 1350 degrees across the (a + L) phase area, <em>being 72wt % of Ni.</em>

4 0
3 years ago
Hydraulic fluid is primarily used to
Lerok [7]

Answer:

hydraulic flute is energy transfer medium in all hydraulic system this simple function is only achieved by flute that does not easily trap gases trapped gas and forming problems should bring a higher level of compressibility to a fluid than its usual at a point to support a very steep pass trekking system

8 0
3 years ago
Other questions:
  • A device is needed to accelerate a 3000 lb vehicle into a barrier with constant velocity to test its 5 mph bumpers. The vehicle
    12·2 answers
  • Consider a two-dimensional incompressible velocity potential phi = ???????? cos theta + ????????theta, where B and L are constan
    8·1 answer
  • Consider the following grooves, each of width W, that have been machined from a solid block of material. (a) For each case obtai
    8·1 answer
  • Considering the two tables below called Orders and OrderLines, how many rows would be returned by this SQL query? SELECT o.Order
    10·1 answer
  • ¿Cómo nos podría ayudar una hoja de cálculo en nuestro estudio?
    11·1 answer
  • The Accenture team is involved in helping a client in the transformation journey using Cloud computing. How is myNav beneficial
    6·1 answer
  • In the situation shown below, what would the Moon look like from Earth? Sun, Earth and Moon Four Moon Views A. View A B. View B
    8·1 answer
  • How do you identify all sensors, functions, and where we can use them?
    12·1 answer
  • What lump sum of money must be deposited in a bank account at present time so that Php 500 monthly can be withdrawn for five yea
    10·1 answer
  • Read the passage.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!