answer.
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
Marat540 [252]
2 years ago
10

Write a Java method, smallestIndex, that takes as its parameters an int array, and returns the index of the (last occurrence of

the) smallest element in the array. Write a program to test your method. Use the following array values: {10 5 15 12 3 16 25 42 3 30}
Engineering
1 answer:
Olenka [21]2 years ago
8 0

Answer:

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        int testArray [] = {10,5,15,12,3,16,25,42,3,30};
  4.        int minIndex = smallestIndex(testArray);
  5.        System.out.println(minIndex);
  6.    }
  7.    public static int smallestIndex(int [] arr){
  8.        int smallest = arr[0];
  9.        int result=0;
  10.        for(int i=1; i < arr.length; i++){
  11.            if(arr[i] <= smallest){
  12.                smallest = arr[i];
  13.                result = i;
  14.            }
  15.        }
  16.        return result;
  17.    }
  18. }

Explanation:

Firstly, we define a method smallestIndex that take one integer array (Line 9).

We create a variable smallest and another variable result to hold the value of smallest number in the array and its index position. We tentatively set the first element of the array as smallest (Line 10-11).

Next, create a for loop to traverse through the array elements starting with index-1 and then check if the current element is smaller or equal to the current smallest value. If so set the current element to smallest variable and set the current index to result variable (Line 14-16).

After the loop return the result (Line 19).

In the main program, we test the method using the sample array and print out the result (Line 4-6). We shall get 8 which is the index position where the last occurrence of the  smallest element found in the array.  

You might be interested in
Water at 70 kPa and 1008C is compressed isentropically in a closed system to 4 MPa. Determine the final temperature of the water
Nikitich [7]

Answer:

The answer is "909.3928  KJ".

Explanation:

70 \ kPa  \ \ and \ \ 100^{\circ}C \\\\s_i= 7.56162\ \frac{kJ}{kgK}\\\\u_i= 2509.39 \ \frac{kJ}{kg}\\\\

The method is isentropic since the cylinders are shielded.

Calculating the work:

w= u_2-u_i \\\\

   = 3418.7728-2509.38 \\\\=909.3928 \ KJ

3 0
2 years ago
Your roommate wants to learn about organizational chart. You can tell her that these charts can tell you all of these about an o
mars1129 [50]

Answer:

Control mechanisms

Explanation:

Organizational chart of any company will give details of different aspects of the company such as the major sub-units of the organization with the names of team leaders for different sub-units, it can also give you the span of control and the division of work within the company. However, the chart can't show you control mechanisms of different departments.

4 0
2 years ago
How does miep build suspense in this passage
siniylev [52]

Then I walked into Mr. and Mrs. Frank's bedroom. On the floor, amidst the chaos of papers and books, my eye lit on the little red-orange checkered, cloth-bound diary that Anne had received from her father on her thirteenth birthday. She loves Anne and respects her work.

I hope this helps you.

3 0
2 years ago
Read 2 more answers
An automobile having a mass of 900 kg initially moves along a level highway at 100 km/h relative to the highway. It then climbs
creativ13 [48]

Answer:

ΔKE=-347.278 kJ

ΔPE= 441.45 kJ

Explanation:

given:

mass m=900 kg

the gravitational acceleration g=9.81 m/s^2

the initial velocity V_{1}=100 km/h-->100*10^3/3600=27.78 m/s

height above the highway h=50 m

h1=0m

the final velocity V_{F}=0 m/s

<u>To find:</u>

the change in kinetic energy ΔKE

the change in potential energy ΔPE

<u>assumption:</u>

We take the highway as a datum

<u>solution:</u>

ΔKE=5*m*(V_{F}^2-V_{1}^2)

      =-347.278 kJ

ΔPE=m*g*(h-h1)

      = 441.45 kJ

5 0
2 years ago
The legend that Benjamin Franklin flew a kite as a storm approached is only a legend—he was neither stupid nor suicidal. Suppose
Delicious77 [7]

Answer: 0.93 mA

Explanation:

In order to calculate the current passing through the water layer, as we have the potential difference between the ends of the string as a given, assuming that we can apply Ohm’s law, we need to calculate the resistance of the water layer.

We can express the resistance as follows:

R = ρ.L/A

In order to calculate the area A, we can assume that the string is a cylinder with a circular cross-section, so the Area of the water layer can be written as follows:

A= π(r22 – r12) = π( (0.0025)2-(0.002)2 ) m2 = 7.07 . 10-6 m2

Replacing by the values, we get R as follows:

R = 1.4 1010 Ω

Applying Ohm’s Law, and solving for the current I:

I = V/R = 130 106 V / 1.4 1010 Ω = 0.93 mA

7 0
2 years ago
Other questions:
  • PDAs with two stacks are strictly more powerful than PDAs with one stack. Prove that 2-stack PDAs are not a valid model for CFLs
    12·1 answer
  • 5 kg of steam contained within a piston-cylinder assembly undergoes an expansion from state 1, where the specific internal energ
    7·1 answer
  • A binary star system consists of two stars of masses m1m1m_1 and m2m2m_2. The stars, which gravitationally attract each other, r
    9·1 answer
  • Two physical properties that have a major influence on the cracking of workpieces, tools, or dies during thermal cycling are the
    13·1 answer
  • Two resistors of values 7.0 and 15.0 Ω are connected in parallel. This combination in turn is hooked in series with a 3.8- Ω res
    7·1 answer
  • A well-insulated tank in a vapor power plant operates at steady state. Saturated liquid water enters at inlet 1 at a rate of 125
    8·1 answer
  • or a metal pipe used to pump tomato paste, the overall heat- transfer coefficient based on internal area is 2 W/(m2 K). The insi
    14·1 answer
  • Benzene vapor at 480°C is cooled and converted to a liquid at 25°C in a continuous condenser. The condensate is drained into 1.7
    15·1 answer
  • Consider the time domain waveforms below on the left. Match waveforms (a) - (e) to their respective frequency spectrum represent
    11·1 answer
  • What should always be done before beginning any diagnosis?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!