Question: solve CHALLENGE ACTIVITY 8.4.2: Finding values in an array. Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements.
solve
CHALLENGE ACTIVITY 8.4.2: Finding values in an array. Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If userValues is {2, 2, 1, 2) and matchValue is 2 , then numMatches should be 3. Your code will be tested with the following values: * NUM_VALS: 4, userValues: {2, 2, 1, 2}, matchValue: 2 (as in the example program above) * NUM_VALS: 5, userValues: {0, 0, 0, 0, 0}, matchValue: 0 * NUM_VALS: 2, userValues: {10, 20}, matchValue: 50 (Notes) Learn how our autograder works 686470.5454358.qx3zqy7 3 public class FindMatchValue { public static void main (String args) { 1 test final int NUM_VALS = 4; passed int userValues = new int [NUM_VALS]; 7 int i; 8 int matchValue; All tests 9 int numMatches = -99; // Assign numMatches with 0 before your for Loop passed 10 11 userValues [0 ] = 2; 12 userValues [ 1 ] = 2; 13 userValues [2] = 1; 14 userValues [ 3 ] = 2; 15 16 matchValue = 2; 17 18 V* Your solution goes here * / 19 20 System out printin( "matchValue: " + matchValue + ". numMatches: " + numMatches)Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
