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]
2 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]2 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
Which of the following is true about modern hydraulic lifts?
kaheart [24]

The modern hydraulic lifts make use of biodegradable fluid to transmit hydraulic power

<em>Question: The options are left out in the question. The details and facts about the modern hydraulic lift are presented here</em>

<em />

Details about the modern hydraulic lifts include;

The development of the  modern hydraulic occurred in the Industrial Revolution to perform task done previously by steam powered elevators  

The power of the hydraulic lift come from the hydraulic cylinder known as the actuator, which in turn is powered by pressurized hydraulic fluid such as oil

The hydraulic fluid is pushed by a piston rod through which energy is capable of being transferred, such that the applied force is multiplied, to provide more power for lifting

<u>Facts about the modern hydraulic lifts include;</u>

  • The dry motor in the modern hydraulic lift is more efficient and consumes 20% less energy
  • It comprises of valves that are controlled electronically such that the response is much rapid and the energy consumption is reduced by a further 20%
  • The cars used in the modern lift are lighter, as well as the slings, which reduces the power usage by 20%
  • It makes use of chemicals which are environmentally friendly as hydraulic fluid
  • The flash point of the fluid used is higher, as well as it posses 50% lower compressibility as well elasticity

Learn more here:

brainly.com/question/16942803

6 0
1 year ago
An aluminum alloy tube with an outside diameter of 3.50 in. and a wall thickness of 0.30 in. is used as a 14 ft long column. Ass
slega [8]

Answer:

slenderness ratio = 147.8

buckling load = 13.62 kips

Explanation:

Given data:

outside diameter is 3.50 inc

wall thickness 0.30 inc

length of column is 14 ft

E = 10,000 ksi

moment of inertia = \frac{\pi}{64 (D_O^2 -D_i^2)}

I = \frac{\pi}{64}(3.5^2 -2.9^2) = 3.894 in^4

Area = \frac{\pi}{4} (3.5^2 -2.9^2) = 3.015 in^2

radius = \sqrt{\frac{I}{A}}

r = \sqrt{\frac{3.894}{3.015}

r = 1.136 in

slenderness ratio = \frac{L}{r}

                              = \frac{14 *12}{1.136} = 147.8

buckling load = P_cr = \frac{\pi^2 EI}}{l^2}

P_{cr} = \frac{\pi^2 *10,000*3.844}{( 14\times 12)^2}

P_{cr} = 13.62 kips

3 0
2 years ago
Who was part of dempwolf his firm when he first started
Zinaida [17]

Explanation:

Dempwolf created by John Augustus, Among the most prominent innovative solutions in Southern California Pennsylvania was established by Dempwolf with  brother Reinhardt or uncle's son Frederick entered the company of J.A. Dozens of structures in 10 states were engineered by Dempwolf.

5 0
2 years ago
What is an advantage of using a fully integrated cloud-based data analytics platform?
sweet [91]

Answer:

It gives decision-makers the processing capacity they need to turn raw data into useful knowledge.

Explanation:

Data analysis and the associated cycles (data integration, aggregation, hoarding, and revealing) are totally or partially directed in the cloud with cloud analytics.

3 0
2 years ago
What is the De Broglie wavelength of an electron under 150 V acceleration?
yanalaym [24]

Answer:

0.1 nm

Explanation

Potential deference of the electron is given as V =150 V

Mass of electron m=9.1\times 10^{-31}

Let the velocity of electron = v

Charge on the electron =1.6\times 10^{-19}C

plank's constant h =6.67\times 10^{-34}

According to energy conservation eV =\frac{1}{2}mv^2

v=\sqrt{\frac{2eV}{M}}=\sqrt{\frac{2\times 1.6\times 10^{-19}\times 150}{9.1\times 10^{-31}}}=7.2627\times 10^{-6}m/sec

Now we know that De Broglie wavelength \lambda =\frac{h}{mv}=\frac{6.67\times 10^{-34}}{9.1\times 10^{-31}\times 7.2627\times10^6 }=0.100\times 10^{-9}m=0.1nm

4 0
3 years ago
Read 2 more answers
Other questions:
  • 5. Which of these least accurately describes what happens when abnormal combustion raises the temperature and pressure inside th
    8·1 answer
  • Find the equivalent impedance Zeq seen by the source when Vs = 2 cos (5t) v, C = 0.2 F, R = 1 Ω and L = 0.1 H. (Give angles in d
    12·1 answer
  • You must signal [blank] before any turn or lane change.
    11·1 answer
  • Use the map to complete the table by selecting the boxes that best describe how ocean currents affect the
    14·1 answer
  • Question 21(Multiple Choice
    11·2 answers
  • A light bar AD is suspended from a cable BE and supports a 20-kg block at C. The ends A and D of the bar are in contact with fri
    13·1 answer
  • I need this asap thank you :) plzzzzz When the spring on a mousetrap car is fully unwound, the force acting on the car is _____.
    11·1 answer
  • What is the condition for maximum efficiency in a DC motor?
    15·1 answer
  • 6
    10·2 answers
  • Technician A says that the starter solenoid switches the high current on and off. Technician B says that the solenoid on the sta
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!