1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lapatulllka [165]
3 years ago
14

Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If user

Values is {2, 1, 2, 2} and matchValue is 2 , then numMatches should be 3. Your code will be tested with the following values: userValues: {2, 1, 2, 2}, matchValue: 2 userValues: {0, 0, 0, 0}, matchValue: 0 userValues: {20, 50, 70, 100}, matchValue: 10 import java.util.Scanner; public class FindMatchValue { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); 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 matchValue = scnr.nextInt(); for (i = 0; i < userValues.length; ++i) { userValues[i] = scnr.nextInt(); } /* Your solution goes here */ System.out.println("matchValue: " + matchValue + ", numMatches: " + numMatches); } }
Engineering
1 answer:
Thepotemich [5.8K]3 years ago
8 0

Answer:

import java.util.Scanner;

public class FindMatchValue {

  public static void main (String [] args) {

     Scanner scnr = new Scanner(System.in);

     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

     matchValue = scnr.nextInt();

     for (i = 0; i < userValues.length; ++i) {

        userValues[i] = scnr.nextInt();

     }

     /* Your solution goes here */

         numMatches = 0;

     for (i = 0; i < userValues.length; ++i) {

        if(userValues[i] == matchValue) {

                       numMatches++;

                }

     }

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

  }

}

You might be interested in
Dimension these please.
Svetach [21]

Answer:

86

Explanation:

3 0
2 years ago
Match the descriptions to the respective stage of team
Svetlanka [38]

Answer:

development

forming stage - The team transitions into this stage after completion of its first successful project.

storming stage - In this stage, comfort and trust between the members is high.

norming stage - In this stage, the team members come together for the first time.

performing stage- In this stage, the members have a better idea of what the team expects of them.

5 0
3 years ago
Which statement best describes an integrated circuit?
olganol [36]

Answer:b

Explanation:

5 0
3 years ago
Print that out and do it lol but seriously
ludmilkaskok [199]
The picture won’t load
8 0
3 years ago
Hi how they are?(*^▽^*)(*^▽^*)
madreJ [45]

Answer:

Hello How Are You Today?

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • A block is sliding on a level surface of varying materials, and so its effective coefficient of friction is variable, 0.1t, wher
    6·1 answer
  • What is 29*69+98-78/36=
    9·2 answers
  • What was the first prototype of the artificial tree like?
    5·1 answer
  • 1. The area of the given triangle is 25 square units. What is the value of x?<br> X+2
    8·1 answer
  • The cross-section of a rough, rectangular, concrete() channel measures . The channel slope is 0.02ft/ft. Using the Darcy-Weisbac
    8·1 answer
  • 4-6. A vertical cylindrical storage vessel is 10 m high and 2 m in diameter. The vessel contains liquid cyclohexane currently at
    7·1 answer
  • If 65 gallons of hydraulic oil weighs 350lb, what is the specific weight of the oil in lb/ft^3?
    14·1 answer
  • determine the optimum compressor pressure ratio specific thrust fuel comsumption 2.1 220k 1700k 42000 1.004
    8·1 answer
  • Two basic types of mechanical fuel injector systems?​
    13·2 answers
  • The advantage of an interferometer is that
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!