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
Que cambiaría personalmente en esos momentos de cuarentena​
Natali5045456 [20]
No poder salir sin estar con la duda de que si una persona con la que estas cercas tendría el virus , no poder visitar a ciertas personas
6 0
3 years ago
Select the correct answer.
goblinko [34]

Answer:

b

Explanation:

8 0
2 years ago
Help pls put them in order for me??
Natalija [7]

Answer: i can't see the hole thing?

Explanation:

3 0
3 years ago
Read 2 more answers
Which statement is true about dynamic microphones?
Xelga [282]

Answer:

b they have high sensitivity to surrounding sound

Explanation:

tell me it's correct or not

if it's correct so I hope it is helpful for you

but no so I am sorry

6 0
2 years ago
Read 2 more answers
Is It Safe to Use LinkedIn Automation?
Stolb23 [73]

Answer:

A lot of people have claimed that they lost their full-established accounts after using LinkedIn automation tools. LinkedIn detected the activity and blocked their accounts.  

But it’s not the tool that causes spam, it’s the approach you adopt while using these tools.  

Many people think that LinkedIn automation tools(LinkedCamp) can generate leads magically over the night. They send thousands of connection requests and messages using automation and as a result, LinkedIn detects their activity.  This is not how it works. You need a proper strategy to leverage the potential of these tools. Even the best LinkedIn automation tools cannot guarantee success if you try to overdo the activities.

6 0
3 years ago
Read 2 more answers
Other questions:
  • The "fathers of the Internet" are Vinton Cerf and ________. Select one: A. Robert Kahn B. Robert Cailliau C. Tim Berners-Lee D.
    11·1 answer
  • What is the main purpose of broadcasting via satellite? A. To enable signal reception at night B. To convert analog signals to d
    5·1 answer
  • The United States Army retains a history of all equipment acquisition from approval of requirements through funding, authorizing
    13·1 answer
  • A blank is a copy of one or more files that is made in case the original become lost or damaged
    7·1 answer
  • Which part(s) of CAIN is realized through the use of message digest functions and hashes?
    14·1 answer
  • In addition to format commands that are found in the ribbon, which option is available for more extensive formatting?
    11·1 answer
  • PLEASE HURRY!!!!
    8·2 answers
  • There are parallels between the trust models in Kerberos and Public Key Infrastructure (PKI). When we compare them side by side,
    15·1 answer
  • When you check your hard drive to see how much space is available, you are checking your
    15·1 answer
  • Apply the Fill - Teal, Accent 4, Soft Bevel text effect (the 5th
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!