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
a piping system has an internal air pressure of 1,500 kpa. In addition to being subject to the air pressure, the piping supports
Alik [6]

Answer:

See explaination

Explanation:

please kindly see attachment for the step by step solution of the given problem.

5 0
4 years ago
What is the magnitude of the maximum stress that exist at the tip of an internal crack having a radius of curvature of 1.9 x 10-
Hitman42 [59]

Answer:

2800 [MPa]

Explanation:

In fracture mechanics, whenever a crack has the shape of a hole, and the stress is perpendicular to the orientation of such, we can use a simple formula to calculate the maximum stress at the crack tip

\sigma_{m} = 2 \sigma_{p} (\frac{l_{c}}{r_{c}})^{0.5}

Where \sigma_{m} is the magnitude of he maximum stress at the tip of the crack, \sigma_{p} is the magnitude of the tensile stress, l_{c} is 1/2 the length of the internal crack, and r_{c} is the radius of curvature of the crack.

We have:

r_{c}=1.9*10^{-4} [mm]

l_{c}=3.8*10^{-2} [mm]

\sigma_{c}=140 [MPa]

We replace:

\sigma_{m} = 2*(140 [MPa])*(\frac{\frac{3.8*10^{-2} [mm]}{2}}{1.9*10^{-4} [mm]})^{0.5}

We get:

\sigma_{m} = 2*(140 [MPa])*(\frac{\frac{3.8*10^{-2} [mm]}{2}}{1.9*10^{-4} [mm]})^{0.5}=2800 [MPa]

5 0
3 years ago
Two players find themselves in a legal battle over a patent. The patent is worth 20 for each player, so the winner would receive
Alborosie

Answer:

The solution and complete explanation for the above question and mentioned conditions is given below in the attached document.i hope my explanation will help you in understanding this particular question.

Explanation:

5 0
3 years ago
Question 5
likoan [24]

Answer:

worth of being noticed

Explanation:

i had this in iready it’s correct trust me

8 0
3 years ago
Read 2 more answers
Basic concepts surrounding electrical circuitry?​
Elanso [62]
Hopefully that helps you out and is this for history or science?

3 0
3 years ago
Other questions:
  • Carbon dioxide (CO2) at 1 bar, 300 K enters a compressor operating at steady state and is compressed adiabatically to an exit st
    11·1 answer
  • How dose iorn get forged itno steel?
    10·1 answer
  • heavy ball with a weight of 150 N is hung from the ceiling of a lecture hall on a 4.5-m-long rope. The ball is pulled to one sid
    9·1 answer
  • What way the Robotics field is going to impact 1. Industry and productivity 2 . Environment 3. Medical field 4. Economics. From
    15·1 answer
  • Automobiles must be able to sustain a frontal impact. Specifically, the design must allow low speed impacts with little damage,
    9·1 answer
  • Write a function called largest3 which takes 3 numbers as parameters and returns the largest of the 3. Write a program which tak
    12·1 answer
  • : THE NEXT BIG THING In this lesson, you learned about two revolutionary new ideas that have engineers hard at work. There are m
    13·1 answer
  • Which of the following is an example of a pulley?
    10·2 answers
  • PLS HELP!!!
    5·2 answers
  • What documentation is required when a pilot has performed preventive maintenance on an aircraft?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!