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 parallel plates capacitor is filled with a dielectric of relative permittivity ε = 12 and a conductivity σ = 10^-10 S/m. The c
monitta

Answer:

t = 1.06 sec

Explanation:

Once disconnected from the battery, the capacitor discharges through the internal resistance of the dielectric, which can be expressed as follows:

R = (1/σ)*d/A, where d is is the separation between plates, and A is the area of one of  the plates.

The capacitance C , for a parallel plates capacitor filled with a dielectric of a relative permittivity ε, can be expressed in this way:

C = ε₀*ε*A/d = 8.85*10⁻¹² *12*A/d

The voltage in the capacitor (which is proportional to the residual charge as it discharges through the resistance of the dielectric) follows an exponential decay, as follows:

V = V₀*e(-t/RC)

The product RC (which is called the time constant of the circuit) can be calculated as follows:

R*C = (1/10⁻¹⁰)*d/A*8.85*10⁻¹² *12*A/d

Simplifying common terms, we finally have:

R*C = 8.85*10⁻¹² *12 / (1/10⁻¹⁰) sec = 1.06 sec

If we want to know the time at which the voltage will decay to 3.67 V, we can write the following expression:

V= V₀*e(-t/RC) ⇒ e(-t/RC) = 3.67/10 ⇒ -t/RC = ln(3.67/10)= -1

⇒ t = RC = 1.06 sec.

3 0
3 years ago
It is desired to produce and aligned carbon fiber-epoxy matrix composite having a longitudinal tensile strength of 630 MPa. Calc
ratelena [41]

Answer:

The answer is below

Explanation:

Given that:

Diameter (D) = 0.03 mm = 0.00003 m, length (L) = 2.4 mm = 0.0024 m, longitudinal tensile strength (\sigma_{cd})=630\ MPa = 630*10^6\ Pa, Fracture strength

(\sigma_f)=5100\ MPa=5100*10^6\ Pa,fiber-matrix\ stres(\sigma_m)=17.5\ MPa=17.5*10^6\ Pa,matrix\ strength=\tau_c=17\ MPa=17 *10^6\ Pa

a) The critical length (L_c) is given by:

L_c=\sigma_f*(\frac{D}{2*\tau_c} )=5100*10^6*\frac{0.00003}{2*17*10^6}=0.0045\ m=4.5\ mm

The critical length (4.5 mm) is greater than the given length, hence th composite can be produced.

b) The volume fraction (Vf) is gotten from the formula:

\sigma_{cd}=\frac{L*\tau_c}{D}*V_f+\sigma_m(1-V_f)\\\\V_f=\frac{\sigma_{cd}-\sigma_{m}}{\frac{L*\tau_c}{D}-\sigma_{m}}  \\\\Substituting:\\\\V_f=\frac{630*10^6-17.5*10^6}{\frac{0.0024*17*10^6}{0.00003} -17.5*10^6} \\\\V_f=0.456

6 0
3 years ago
1. Consider a city of 10 square kilometers. A macro cellular system design divides the city up into square cells of 1 square kil
kakasveta [241]

Answer:

a) n = 1000\,users, b)\Delta t_{min} = \frac{1}{30}\,h, \Delta t_{max} = \frac{\sqrt{2} }{30}\,h, \Delta t_{mean} = \frac{1 + \sqrt{2} }{60}\,h, c) n = 10000000\,users, \Delta t_{min} = \frac{1}{3000}\,h, \Delta t_{max} = \frac{\sqrt{2} }{3000}\,h, \Delta t_{mean} = \frac{1 + \sqrt{2} }{6000}\,h

Explanation:

a) The total number of users that can be accomodated in the system is:

n = \frac{10\,km^{2}}{1\,\frac{km^{2}}{cell} }\cdot (100\,\frac{users}{cell} )

n = 1000\,users

b) The length of the side of each cell is:

l = \sqrt{1\,km^{2}}

l = 1\,km

Minimum time for traversing a cell is:

\Delta t_{min} = \frac{l}{v}

\Delta t_{min} = \frac{1\,km}{30\,\frac{km}{h} }

\Delta t_{min} = \frac{1}{30}\,h

The maximum time for traversing a cell is:

\Delta t_{max} = \frac{\sqrt{2}\cdot l }{v}

\Delta t_{max} = \frac{\sqrt{2} }{30}\,h

The approximate time is giving by the average of minimum and maximum times:

\Delta t_{mean} = \frac{1+\sqrt{2} }{2}\cdot\frac{l}{v}

\Delta t_{mean} = \frac{1 + \sqrt{2} }{60}\,h

c) The total number of users that can be accomodated in the system is:

n = \frac{10\times 10^{6}\,m^{2}}{100\,m^{2}}\cdot (100\,\frac{users}{cell} )

n = 10000000\,users

The length of each side of the cell is:

l = \sqrt{100\,m^{2}}

l = 10\,m

Minimum time for traversing a cell is:

\Delta t_{min} = \frac{l}{v}

\Delta t_{min} = \frac{0.01\,km}{30\,\frac{km}{h} }

\Delta t_{min} = \frac{1}{3000}\,h

The maximum time for traversing a cell is:

\Delta t_{max} = \frac{\sqrt{2}\cdot l }{v}

\Delta t_{max} = \frac{\sqrt{2} }{3000}\,h

The approximate time is giving by the average of minimum and maximum times:

\Delta t_{mean} = \frac{1+\sqrt{2} }{2}\cdot\frac{l}{v}

\Delta t_{mean} = \frac{1 + \sqrt{2} }{6000}\,h

8 0
3 years ago
Use the concept that y = c, −[infinity] &lt; x &lt; [infinity], is a constant function if and only if y' = 0 to determine whethe
attashe74 [19]

Answer:

attached below

Explanation:

5 0
3 years ago
The seers were of the opinion that_____ . *
AURORKA [14]

Answer:

✔️a healthy mind resides in a healthy body.

Explanation:

The seers were of the opinion that "a healthy mind resides in a healthy body."

Just like the English translation of a famous quotation from Thales, pre-Socratic Greek philosopher puts it "a sound mind in a sound body"; which tries to demonstrate the close connections that exists in bodily well-being and one's ability to enjoy life.

The seers were actually of the opinion that a healthy mind resides in a healthy body. It implies that there is connection between the body and the mind. When the body catches an illness, the mind and other parts of the body are affected. When our minds are not healthy, it affects the effective functioning of the body.

So, a healthy mind will definitely be found in a healthy body.

4 0
3 years ago
Other questions:
  • Marcelo es muy bueno resolviendo adivinanzas y acertijos. Por eso, estaba totalmente disgustado cuando se dio cuenta de que no e
    12·1 answer
  • CNG is a readily available alternative to
    5·1 answer
  • Technician A says that 18 gauge AWG wire can carry more current flow that 12 gauge AWG wire. Technician B says that metric wire
    9·1 answer
  • Calculate the molar heat capacity of a monatomic non-metallic solid at 500K which is characterized by an Einstein temperature of
    8·1 answer
  • What are the different branches of engineering involved in manufacturing a general-purpose elevator?
    6·1 answer
  • You are a technical writer for Landson Toy Company. Landson has just designed a new, more durable swing set for 6- to 10-year-ol
    9·1 answer
  • A steel plate has a hole drilled through it. The plate is put into a furnace and heated. What happens to the size of the inside
    9·1 answer
  • Help thank you &lt;3 :DDD
    13·1 answer
  • If an elevator repairer observes that cables begin to fray after 15 years, what process might he or she use to create a maintena
    11·1 answer
  • Help please i will give brainlist
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!