Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
final int NUM_VALS = 4;
int[] userValues = new int[NUM_VALS];
int numMatches = 0;
System.out.print("Enter the match value: ");
int matchValue = input.nextInt();
for (int i=0; i<NUM_VALS; i++){
System.out.print("Enter the value: ");
userValues[i] = input.nextInt();
}
for (int i=0; i<NUM_VALS; i++){
if (matchValue == userValues[i]){
numMatches ++;
}
}
System.out.println("There are " + numMatches + " " + matchValue + "'s in the user values.");
}
}
Explanation:
Initialize the variables
Ask the user to enter the match value
Create a for loop to get the user values
Create another for loop to check if the match value is equal to any of the user values. If it is, increment the number of matches by 1
When the loop is done, print the number of matches and the match value