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
Saturated water vapor undergoes a throttling process from 1bar to a 0.35bar. What is the change in temperature for this process?
mamaluj [8]

Answer:

-25.63°C.

Explanation:

We know that throttling is a constant enthalpy process

      h_1=h_2

From steal table

We know that if we know only one property in side the dome then we will find the other property by using steam property table.

  Temperature at saturation pressure 1 bar is 99.63°C and  Temperature at saturation pressure 0.35 bar is about 74°C .

So from above we can say that change in temperature is -25.63°C.

But there is no any option for that .

4 0
3 years ago
The period of a pendulum T is assumed to depend only on the mass m, the length of the pendulum `, the acceleration due to gravit
zzz [600]

Answer:

The expression is shown in the explanation below:

Explanation:

Thinking process:

Let the time period of a simple pendulum be given by the expression:

T = \pi \sqrt{\frac{l}{g} }

Let the fundamental units be mass= M, time = t, length = L

Then the equation will be in the form

T = M^{a}l^{b}g^{c}

T = KM^{a}l^{b}g^{c}

where k is the constant of proportionality.

Now putting the dimensional formula:

T = KM^{a}L^{b}  [LT^{-} ^{2}]^{c}

M^{0}L^{0}T^{1} = KM^{a}L^{b+c}

Equating the powers gives:

a = 0

b + c = 0

2c = 1, c = -1/2

b = 1/2

so;

a = 0 , b = 1/2 , c = -1/2

Therefore:

T = KM^{0}l^{\frac{1}{2} } g^{\frac{1}{2} }

T = 2\pi \sqrt{\frac{l}{g} }

where k = 2\pi

8 0
3 years ago
What does the word “robot” mean? A.Clone B. Athlete C. Servant D. Actor
hram777 [196]

Answer:

a. clone

Explanation:

4 0
3 years ago
Radioactive wastes generating heat at a rate of 3 x 106 W/m3 are contained in a spherical shell of inner radius 0.25 m and outsi
MariettaO [177]

Answer:

Inner surface temperature= 783K.

Outer surface temperature= 873K

Explanation:

Parameters:

Heat,e= 3×10^6 W/m^3

Inner radius = 0.25 m

Outside radius= 0.30 m

Temperature at infinity, T(¶)= 10°c = 273. + 10 = 283K.

Convection coefficient,h = 500 W/m^2 . K

Temperature of the surface= T(s) = ?

Temperature of the inner= T(I) =?

STEP 1: Calculate for heat flux at the outer sphere.

q= r × e/3

This equation satisfy energy balance.

q= 1/3 ×3000000(W/m^3) × 0.30 m

= 3× 10^5 W/m^2.

STEP 2: calculus the temperature for the surface.

T(s) = T(¶) + q/h

T(s) = 283 + 300000( W/m^2)/500(W/m^2.K)

T(s) = 283+600

T(s)= 873K.

TEMPERATURE FOR THE OUTER SURFACE is 873 kelvin.

The same TWO STEPS are use for the calculation of inner temperature, T(I).

STEP 1: calculate for the heat flux.

q= r × e/3

q= 1/3 × 3000000(W/m^3) × 0.25 m

q= 250,000 W/m^2

STEP 2:

calculate the inner temperature

T(I) = T(¶) + q/h

T(I) = 283K + 250,000(W/m^2)/500(W/m^2)

T(I) = 283K + 500

T(I) = 783K

INNER TEMPERATURE IS 783 KELVIN

5 0
3 years ago
What are the advantages of studying a scheduled course over a more freeform one?
anyanavicka [17]

Answer:

Taking responsibility for your own learning makes it easier to identify your strengths and weaknesses. Once these have been identified you can work on a learning plan that focuses on the areas that you need most help with, increasing the speed of your learning, and build the skills you have been trying to perfect.

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • The volume at a section of a 2-lane highway is 1800 vph in each direction and the density is approximately 30 bpm. A slow moving
    10·1 answer
  • Magnesium sulfate has a number of uses, some of which are related to the ability of the anhydrate form to remove water from air
    15·1 answer
  • What is the composition, in atom percent, of an alloy that contains 44.5 lbmof Ag, 83.7 lbmof Au, and 5.3 lbmof Cu? What is the
    9·1 answer
  • By using order of magnitude analysis, the continuity and Navier-Stokes equations can be simplified to the Prandtl boundary-layer
    9·1 answer
  • A window‐mounted air‐conditioning unit (AC) removes energy by heat transfer from a room, and rejects energy by heat transfer to
    13·1 answer
  • Principals of Construction intro
    11·1 answer
  • Which fields of engineering use fluid power? Explain how these fields make use of fluid power systems: water supply, agricultura
    10·1 answer
  • Estimate the maximum expected thermal conductivity for a Cermet that contains 58 vol% titanium carbide (TiC) particles in a coba
    8·1 answer
  • Which type of engineer is needed in the following scenario?
    8·2 answers
  • 8. What are used by the project architect to depict different building systems and to show how they correlate to one anothe
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!