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
Marat540 [252]
4 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]4 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
A railcar with an overall mass of 78,000 kg traveling with a speed vi is approaching a barrier equipped with a bumper consisting
sergij07 [2.7K]

Answer:

v₀ = 2,562 m / s  = 9.2 km/h

Explanation:

To solve this problem let's use Newton's second law

              F = m a = m dv / dt = m dv / dx dx / dt = m dv / dx v

              F dx = m v dv

We replace and integrate

            -β ∫ x³ dx = m ∫ v dv

            β x⁴/ 4 = m v² / 2

We evaluate between the lower (initial) integration limits v = v₀, x = 0 and upper limit v = 0 x = x_max

        -β (0- x_max⁴) / 4 = ½ m (v₀²2 - 0)

         x_max⁴ = 2 m /β   v₀²

         

Let's look for the speed that the train can have for maximum compression

         x_max = 20 cm = 0.20 m

         

         v₀ =√(β/2m)   x_max²

Let's calculate

          v₀ = √(640 106/2 7.8 104)    0.20²

          v₀ = 64.05  0.04

          v₀ = 2,562 m / s

          v₀ = 2,562 m / s (1lm / 1000m) (3600s / 1h)

          v₀ = 9.2 km / h

5 0
3 years ago
A cylindrical tank is required to contain a gage pressure 560 kPa . The tank is to be made of A516 grade 60 steel with a maximum
adoni [48]

Answer:

5.6 mm

Explanation:

Given that:

A cylindrical tank is required to contain a:

Gage Pressure P = 560 kPa

Allowable normal stress \sigma = 150 MPa = 150000 Kpa.

The inner diameter of the tank = 3 m

In a closed cylinder  there exist both the circumferential stress and the longitudinal stress.

Circumferential stress \sigma = \dfrac{pd}{2t}

Making thickness t the subject; we have

t = \dfrac{pd}{2* \sigma}

t = \dfrac{560000*3}{2*150000000}

t = 0.0056 m

t = 5.6 mm

For longitudinal stress.

\sigma = \dfrac{pd}{4t}

t= \dfrac{pd}{4*\sigma }

t = \dfrac{560000*3}{4*150000000}

t = 0.0028  mm

t = 2.8 mm

From the above circumferential stress and longitudinal stress; the stress with the higher value will be considered ; which is circumferential stress and it's minimum value  with the maximum thickness = 5.6 mm

8 0
4 years ago
You are using a Geiger counter to measure the activity of a radioactive substance over the course of several minutes. If the rea
Reika [66]

Answer: 33.35 minutes

Explanation:

A(t) = A(o) *(.5)^[t/(t1/2)]....equ1

Where

A(t) = geiger count after time t = 100

A(o) = initial geiger count = 400

(t1/2) = the half life of decay

t = time between geiger count = 66.7 minutes

Sub into equ 1

100=400(.5)^[66.7/(t1/2)

Equ becomes

.25= (.5)^[66.7/(t1/2)]

Take log of both sides

Log 0.25 = [66.7/(t1/2)] * log 0.5

66.7/(t1/2) = 2

(t1/2) = (66.7/2 ) = 33.35 minutes

4 0
3 years ago
Question in image. Question from OSHA.
marin [14]

Answer:

2

Explanation:

my sister did this and its the answer

3 0
3 years ago
Read 2 more answers
What is the multiplicity of the root x = -4?
just olya [345]

Answer:

See explanation

Explanation:

The multiplicity of  a root of a polynomial equation is the number of times the root repeats.

Let x=a be the root of f(x), then;

(x-a)^1=0 has a multiplicity of 1.

(x-a)^2=0 has a multiplicity of 2.

(x-a)^3=0 has a multiplicity of 3.

(x-a)^m=0 has a multiplicity of m, where m is a positive integer.

We were given the root x=-4.

If f(x)=(x+4)(x-6)^3

Then the multiplicity of the root x=-4 is 1.

If  f(x)=(x+4)^4(x-6)^3

Then the multiplicity of the root x=-4 is 4.

Since the polynomial function or equation is not given in the question, we cannot determine the multiplicity of this root.

But I hope with this explanation, you can refer to the original(complete) question and choose the correct answer.

8 0
3 years ago
Other questions:
  • An alloy in the A-B system is 40% B and is within the α + β two phase field, where the a phase contains 5% B and the β phase con
    11·1 answer
  • A horizontal curve is to be designed for a two-lane road in mountainous terrain. The following data are known: Intersection angl
    7·1 answer
  • Consider a nickel wall separating hydrogen gas that is maintained on one side at 5 atm and on the opposite at 3 atm. If the temp
    9·1 answer
  • A cylindrical metal specimen having an original diameter of 11.34 mm and gauge length of 53.3 mm is pulled in tension until frac
    7·1 answer
  • What are the four essential components of a UAS?
    12·1 answer
  • Please help and thank u so much
    6·1 answer
  • 1.8 A water flow of 4.5 slug/s at 60 F enters the condenser of steam turbine and leaves at 140 F. Determine the heat transfer ra
    13·1 answer
  • 1. You should
    11·2 answers
  • Question # 8
    15·1 answer
  • A jointed arm robot can rotate on the following 6 axes?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!