Created
October 3, 2017 20:25
-
-
Save viveknarang/49db56c810e4b53dd9736dbfa793a924 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
numMatches = 0; | |
/* Your solution goes here */ | |
for(i = 0 ; i < userValues.length; i++) { | |
if (userValues[i] == matchValue) { | |
numMatches++; | |
} | |
} | |
System.out.println("matchValue: " + matchValue + ", numMatches: " + numMatches); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment