Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started