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
Select the correct answer.
cricket20 [7]

Answer:

A.

The power generated by a wind farm is not constant because of irregular wind patterns.

5 0
3 years ago
A cruise missile under test is moving horizontally at Ma =2 in the atmosphere at an elevation of 2000 m (Air temperature is 2 °C
telo118 [61]

Answer: the half-angle "alpha" of the Mach cone = 30⁰

Explanation:

To calculate the  half-angle "alpha" of the Mach cone.

we say ;

Sin∝ = 1 / Ma

given that Ma = 2

now we substitute

Sin∝ = 1 / 2

Sin∝ = 0.5

∝ = Sin⁻¹ 0.5

∝ = 30⁰

Therefore, the half-angle "alpha" of the Mach cone is 30⁰

3 0
3 years ago
214Bi83 --&gt; 214Po84 + eBismuth-214 undergoes first-order radioactive decay to polonium-214 by the release of a beta particle,
Zolol [24]

Answer:

(C) ln [Bi]

Explanation:

Radioactive materials will usually decay based on their specific half lives. In radioactivity, the plot of the natural logarithm of the original radioactive material against time will give a straight-line curve. This is mostly used to estimate the decay constant that is equivalent to the negative of the slope. Thus, the answer is option C.

3 0
3 years ago
Read 2 more answers
What are the four categories of engineering materials used in manufacturing?
alexgriva [62]

Answer:

metals, composite, ceramics and polymers.

Explanation:

The four categories of engineering materials used in manufacturing are metals, composite, ceramics and polymers.

i) Metals: Metals are solids made up of atoms held by matrix of electrons. They are good conductors of heat and electricity, ductile and strong.

ii) Composite: This is a combination of two or more materials. They have high strength to weight ratio, stiff, low conductivity. E.g are wood, concrete.

iii) Ceramics: They are inorganic, non-metallic crystalline compounds with high hardness and strength as well as poor conductors of electricity and heat.

iv) Polymers: They  have low weight and are poor conductors of electricity and heat

8 0
3 years ago
The human eye, as well as the light-sensitive chemicals on color photographic film, respond differently to light sources with di
jeka57 [31]

Answer:

a) at T = 5800 k  

  band emission = 0.2261

at T = 2900 k

  band emission = 0.0442

b) daylight (d) = 0.50 μm

    Incandescent ( i ) =  1 μm

Explanation:

To Calculate the band emission fractions we will apply the Wien's displacement Law

The ban emission fraction in spectral range λ1 to λ2 at a blackbody temperature T can be expressed as

F ( λ1 - λ2, T ) = F( 0 ----> λ2,T) - F( 0 ----> λ1,T )

<em>Values are gotten from the table named: blackbody radiati</em>on functions

<u>a) Calculate the band emission fractions for the visible region</u>

at T = 5800 k  

  band emission = 0.2261

at T = 2900 k

  band emission = 0.0442

attached below is a detailed solution to the problem

<u>b)calculate wavelength corresponding to the maximum spectral intensity</u>

For daylight ( d ) = 2898 μm *k / 5800 k  = 0.50 μm

For Incandescent ( i ) = 2898 μm *k / 2900 k = 1 μm

3 0
3 years ago
Other questions:
  • A tire-pressure monitoring system warns you with a dashboard alert when one of your car tires is significantly under-inflated.
    6·1 answer
  • Water at a pressure of 3 bars enters a short horizontal convergent channel at 3.5 m/s. The upstream and downstream diameters of
    10·1 answer
  • A food-services company with a 480 V, three-phase service entrance has the following set of loads:  A 7 ton walk-in refrigerati
    13·1 answer
  • Tech A says that a gear set that has a drive gear with 9 teeth and a driven gear with 27 teeth has a gear ratio of 3:1. Tech B s
    7·1 answer
  • This search compares the target value with the middle element in the collection, then ignores the half of the collection in whic
    11·1 answer
  • 1. advantages of 2 pulley system
    13·1 answer
  • What does an engineer do? List as many types of engineers as you can.
    9·1 answer
  • Binary classification algorithm
    9·1 answer
  • Dampness or moisture introduces ____ into the weld, which causes cracking when some metals are welded.
    7·1 answer
  • which of the following is not a general education elective area? group of answer choices humanities/fine arts social/behavioral
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!