Question: Add a loop to the code shown below to count the number of elements in the val array that are greater than or equal to

Add a loop to the code shown below to count the number of elements in the val array that are greater than or equal to 40. Report the count.

public class CountArray { public static void main(String [] args) { int [] val = { 81, 6, 95, 30, 40, 5, 16 }; // Write your loop in the space below: } } 

Your program should generate the following output on the console given the values shown in the val array, above (the loop should work correctly for any values in the val array):

 There were 3 values greater than or equal to 40. 

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!