Created
February 25, 2018 05:16
-
-
Save viveknarang/cce3be68fcd36ef66d0a84b79282f99e to your computer and use it in GitHub Desktop.
This file contains 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; | |
int matchValue; | |
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 < NUM_VALS; i++) { | |
if (userValues[i] == matchValue) { | |
numMatches++; | |
} | |
} | |
System.out.println("matchValue: " + matchValue + ", numMatches: " + numMatches); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment