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
SSSSS [86.1K]
3 years ago
6

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

nd 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;
Computers and Technology
1 answer:
xenn [34]3 years ago
5 0

Answer:

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;

   for(i=0;i<NUM_VALS;i++)

   {

       if(userValues[i]==matchValue)//cheking if the array element is equal to match value.

       {

           numMatches++;

           

       }

   }

   System.out.println(numMatches);//printing the matchvalue.

}

}

Output:-

3

Explanation:

First I have set the value numMatches to 0 before the loop.Then I have user the for loop to iterate over the array.In the for loop I am checking that the array element is equal to the matchValue or not if it is equal then increasing the numMatches by 1.Then at last print the value of numMatches.

You might be interested in
Which file extension indicates a text document? .ppt .tst .pdf .txt
Ber [7]

Answer:

The answer is .txt

Explanation:

6 0
2 years ago
Read 2 more answers
If you are feeling sick and you want to drive somewhere, you should
Ganezh [65]

Answer

Ask someone to drive you.

Explanation

When feeling ill, or even taking medication before driving Is dangerous for the driver and other road users  because it slows reactions and the ability to make rapid corrective actions while driving. Driving while sick  can also have the same effects on a driver as if they were drinking.

5 0
3 years ago
Read 2 more answers
Why Is Jarvis Banned For Life? Literally Don't need to be forever!
Ahat [919]

Answer:

he used aimbot in playground (I think) and made videos of it for entertainment and Epic Games just banned him. I agree.. Epic could have banned him for weeks maybe not not for life.

Explanation:

5 0
3 years ago
jenny wants to create a resume after a two year gap. what should she consider? jenny has a two year gap between her last two job
Lunna [17]

Answer:

functional

Explanation:

Suppose you are pivoting to a certain new company, and you find that your experience is not suited. You are certainly going to highlight your skills that are required for the job. And suppose you are lacking work experience, concerning the position you are opting for. Also, you have many gaps in employment. Then the best format suited to you is functional format.

6 0
3 years ago
Read 2 more answers
Identify the menu under which you'll find the Header and Footer option.
Genrish500 [490]

The answer is B. View.

4 0
3 years ago
Other questions:
  • 10 facts about turbines
    11·2 answers
  • Write a sentence about a mineral you use and how you use it
    12·1 answer
  • ____________ is demonstrated by the processes and procedures that an organization uses to meet the law.A. An auditB. SecurityC.
    15·2 answers
  • Which role involves designing and creating advertisements for marketing purposes?
    14·2 answers
  • If you are running a server , which of the follow operating system would be best suited ?window 10 or macOS
    8·1 answer
  • Which of the following component is required to insert text in multimedia
    8·1 answer
  • What is a best practice when approaching an automation effort?
    6·1 answer
  • How to realize dynamic balance of planar closed-chain leg mechanism?​
    7·2 answers
  • Hellpppppppppppppppp
    13·2 answers
  • Put simply, what tasks do algorithms help computers perform?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!