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
For some metal alloy, a true stress of 345 MPa (50040 psi) produces a plastic true strain of 0.02. How much will a specimen of t
saveliy_v [14]

Complete Question

For some metal alloy, a true stress of 345 MPa (50040 psi) produces a plastic true strain of 0.02. How much will a specimen of this material elongate when a true stress of 411 MPa (59610 psi) is applied if the original length is 470 mm (18.50 in.)?Assume a value of 0.22 for the strain-hardening exponent, n.

Answer:

The elongation is =21.29mm

Explanation:

In order to gain a good understanding of this solution let define some terms

True Stress

       A true stress can be defined as the quotient obtained when instantaneous applied load is divided by instantaneous cross-sectional area of a material it can be denoted as \sigma_T.

True Strain

     A true strain can be defined as the value obtained when the natural logarithm quotient of instantaneous gauge length divided by original gauge length of a material is being bend out of shape by a uni-axial force. it can be denoted as \epsilon_T.

The mathematical relation between stress to strain on the plastic region of deformation is

              \sigma _T =K\epsilon^n_T

Where K is a constant

          n is known as the strain hardening exponent

           This constant K can be obtained as follows

                        K = \frac{\sigma_T}{(\epsilon_T)^n}

No substituting  345MPa \ for  \ \sigma_T, \ 0.02 \ for \ \epsilon_T , \ and  \ 0.22 \ for  \ n from the question we have

                     K = \frac{345}{(0.02)^{0.22}}

                          = 815.82MPa

Making \epsilon_T the subject from the equation above

              \epsilon_T = (\frac{\sigma_T}{K} )^{\frac{1}{n} }

Substituting \ 411MPa \ for \ \sigma_T \ 815.82MPa \ for \ K  \ and  \  0.22 \ for \ n

       \epsilon_T = (\frac{411MPa}{815.82MPa} )^{\frac{1}{0.22} }

            =0.0443

       

From the definition we mentioned instantaneous length and this can be  obtained mathematically as follows

           l_i = l_o e^{\epsilon_T}

Where

       l_i is the instantaneous length

      l_o is the original length

Substituting  \ 470mm \ for \ l_o \ and \ 0.0443 \ for  \ \epsilon_T

             l_i = 470 * e^{0.0443}

                =491.28mm

We can also obtain the elongated length mathematically as follows

            Elongated \ Length =l_i - l_o

Substituting \ 470mm \ for l_o and \ 491.28 \ for \ l_i

          Elongated \ Length = 491.28 - 470

                                       =21.29mm

4 0
3 years ago
Plis 3 conclusiones de este video
vazorg [7]
No hay videos? de cual video estás hablando?
6 0
2 years ago
Between chain, belt and gear drive, which causes more friction?​
loris [4]

Answer:

All of them cause friction

Explanation:

google

6 0
3 years ago
Calculate the theoretical density of FCC iron (eg. austenitic stainless steel). The lattice parameter for FCC iron is 0.357 nm a
Ann [662]

Answer: 12.4 feet

Explanation:

If there is a smooth transition and there is no change in slopes, energy considerations can be used

The cube has a kinetic energy of

ke = mv^2/2 = 10 lbm * 20^2ft^2/s^2 / 2 = 2000 lbm-ft^2 / s^2

At the highest point when there is a gain in potential energy

pe = mgh = 10 lbm * 32.2 ft/s^2 * h ft = 322 lbm ft^2/s^2

If there is no loss in energies,

pe = ke

322h lbm ft^2/s^2 = 2000 lbm ft^2/s^2

h = 2000 /322 = 6.211 (ft)

= h / sin(30) = 12.4 ft

8 0
3 years ago
120 litres of water is discharge from container in 25 seconds. Find the rate of discharge in cumecs.if the discharge took place
notsponge [240]
<h2>Answer:</h2>

Rate of discharge in cumecs: <u>0.0048m³/s</u>.

Velocity flow: <u>24m/s</u>.

<h2>Explanation:</h2>

<h3>1. Find the rate of discharge in cumecs.</h3>

a. Convert from litres to m³.
120L*1000= 120000mL

120000mL=120000cm³

120000cm³/100³=0.12 m³.

b. Rate of discharge.

<em>If  0.12 m³ where discharged in 25 seconds, the rate of discharge is:</em>

0.12m³/25s = 0.0048m³/s.

<em />

<em />

<h3>2. Find the velocity flow.</h3>

Let's refer to the fluid mechanics equation that relates volume flow, area and velocity. This is the formula:

\frac{dV}{dt}=Av; where the expression \frac{dV}{dt} is the volume flow rate (in m³/s); A is the cross-sectional area of the pipe (in m²), and v is the velocity flow (in m/s).

a. Solve the equation for v.

\frac{dV}{dt}=Av\\ \\(\frac{dV}{dt})/A=v\\ \\v=(\frac{dV}{dt})/A

b. Calculate the cross-sectional area of the pipe.

<em>The cross-sectional area of the pipe is a circle. Hence, the formula of this area is:</em>

A=\pi r^{2}

<em>We'll have to convert the diameter to meters, because the formula for flow velocity needs the area in m². Let's go ahead and do that.</em>

<em />50mm/1000=0.05m.

<em>We were given the diameter, and the formula uses the radius, but the radius is just half of the diameter, therefore, we can substitute in toe formula like this:</em>

A=\pi (\frac{0.05}{2} )^{2}=0.0020m^{2}

c. Substitute in the new expression for velocity flow and calculate.

v=(\frac{dV}{dt})/A\\ \\v=(\frac{0.048m^{3} }{1s})/(0.0020m^{2} )\\\\ v= 24m/s

8 0
2 years ago
Other questions:
  • A rigid tank having 25 m3 volume initially contains air having a density of 1.25 kg/m3, then more air is supplied to the tank fr
    12·1 answer
  • The enthalpy of the water entering an actual pump is 500 kJ/kg and the enthalpy of the water leaving it is 550 kJ/kg. The pump h
    10·1 answer
  • Under which of the following conditions is a Type B-1 Fire extinguisher required onboard a motorized vessel?
    14·2 answers
  • When trying to solve a frame problem it will typically be necessary to draw many free body diagrams. a)-True b)-False
    6·1 answer
  • You are given that kc = 10-1 kg eq-1 min-1, ku = 10-3 kg2 eq-2 min-1 and [A]0 = 10 eq kg-1, where kc is the rate constant for a
    15·1 answer
  • Consider atmospheric air at 20°C and a velocity of 30 m/s flowing over both surfaces of a 1-m-long flat plate that is maintained
    11·1 answer
  • In 2009 an explosive eruption covered the island of Hunga Ha'apai in black volcanic ash. What type of succession is this?
    7·1 answer
  • Write the output expression for a NOR gate with inputs , , and .​
    7·1 answer
  • How does data mining help interactive marketing for a business?
    5·1 answer
  • when discussing valve train components, technician a says stamped rocker arms are very strong and may be used in high-horsepower
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!