Write a complete Java method named finalSearch which accep

) Write a complete Java method named finalSearch( ) which accepts two arguments. The first will be an array of integer values named List and the second will be a single integer value named target. The method should return a count (int) of the number of items in the array which are GREATER THAN the given target.

Solution

SearchTest.java


public class SearchTest {

   public static void main(String[] args) {
       int cnt = finalSearch(new int[]{1,2,3,4,5,6,7,8,9}, 5);
       System.out.println(\"Number of itesm greater than 5 is \"+cnt);

   }
   public static int finalSearch(int list[], int target){
       int count = 0;
      
       for(int i=0; i<list.length; i++){
           if(list[i] > target){
               count++;
           }
       }
       return count;
   }
}

Output:

Number of itesm greater than 5 is 4

) Write a complete Java method named finalSearch( ) which accepts two arguments. The first will be an array of integer values named List and the second will be

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site