Question: How does Java use for loops and while loops to search an array? A global array named array 5 2 0 has been declared and

How does Java use for loops and while loops to search an array?
A global array named array520 has been declared and initialized at the top of your code
Below the main() method, write a NEW public static method named findMin5 with no parameters and it returns an
integer
It will contain a for loop that will search the global array array 520 and return the index/subscript of the SMALLEST
item in the array.
Below the main() method, write a NEW public static method named getMax with no parameters and it returns an
integer
It will contain a while loop that will search the global array array520 and return the VALUE of the LARGEST item in
the array.
Understand the difference between the INDEX and the VALUE stored in the array. Look carefully at the example
below:
The smallest number in the array is 10, if you are looking for the INDEX return a 3 because it is in position 3 of the
array
The largest number in the array is 50, if you are looking for the VALUE return a 50 not the index 4 where it is located
Inside the main(0 method:
Declare a local int variable named small and assign it the initial value of -1
Declare a local int variable named max and assign it the initial value of -1
Call the method named findMin5, and assign the return value to small
Call the method named getMax, and assign the return value to max
Print the message 'Method findMin5 output is ' plus the value in the variable small
Print the message 'Method getMax output is ' plus the value in the variable max
 How does Java use for loops and while loops to search

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!