Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java Set numMatches to the number of elements in userValues (having NUM_VALS elements) that equal matchValue. Ex: If matchValue = 2 and userValues =

in java

Set numMatches to the number of elements in userValues (having NUM_VALS elements) that equal matchValue. Ex: If matchValue = 2 and userValues = {2, 2, 1, 2}, then numMatches = 3.

import java.util.Scanner;

public class FindMatchValue { public static void main (String [] args) { final int NUM_VALS = 4; int[] userValues = new int[NUM_VALS]; int i = 0; int matchValue = 0; int numMatches = -99; // Assign numMatches with 0 before your for loop

userValues[0] = 2; userValues[1] = 2; userValues[2] = 1; userValues[3] = 2;

matchValue = 2; /* student solution goes here */

System.out.println("matchValue: " + matchValue + ", numMatches: " + numMatches);

return; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Lo6 Identify several management development methods.

Answered: 1 week ago

Question

LO4 List options for development needs analyses.

Answered: 1 week ago