Write a method howMany that takes two parameters: anarray of integer values iArr
ID: 3614638 • Letter: W
Question
Write a method howMany that takes two parameters: anarray of integer values iArray and an integer valueiVal. The method returns the number of array elements thatare less than the value iVal.
public class Test53{
public staticvoid main(String[] args) {
int[] a = { -1,-4, 8, 0, 7, 9, -6, 3, 4 };
System.out.println("CMSC 130 - Exercise 5.3");
System.out.println("The number of array elements less than 2 is: "+ howMany(a,2));
}
// ... here goes your code for defining the methodhowMany;
Explanation / Answer
please rate - thanks import java.util.*; public class Test53{ public static void main(String[] args) { int[] a = { -1, -4, 8, 0, 7, 9, -6, 3, 4 }; System.out.println("CMSC 130 -Exercise 5.3"); System.out.println("The number ofarray elements less than 2 is: " + howMany(a,2)); } public static int howMany(int a[],int b) {int i,count=0; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.