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
What type of computer is IBM 1401 ?<br><br>​
rjkz [21]

Answer:

The IBM 1401 is a variable-word length decimal computer that was announced by IBM on October 5, 1959.

7 0
2 years ago
the mail merge feature can be used to address the same letter to several different people , true or false
sergij07 [2.7K]
The answer is that it is true.
4 0
2 years ago
Read 2 more answers
Ava calls tech support because she is unable to send information that a customer has requested. The tech support person tells he
Blizzard [7]

Answer:

Outlook as it is a common email aplication which may experience some issues

Explanation:

7 0
3 years ago
How can ascii be used to represent characters in computer system
Furkat [3]

It is a code for representing 128 English characters as numbers, with each letter assigned a number from 0 to 127. For example, the ASCII code for uppercase M is 77. Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another.

7 0
3 years ago
What is the most significant difference between improving an existing process and designing a new process?
san4es73 [151]

The most significant difference between improving an existing process and designing a new process is that as a person is completely working again on a process or designing a new process, there are known to be a lot of unknowns factors that may occur.

<h3>What is the difference about?</h3>

In working or  redoing a process or designing any kind of new process, there are known to be a lot of unknowns factors.

This is said to be the most significant difference that exist between improving a process and designing a new process. This makes a lot of new processes and products to be very focus on meeting their customer's performance needs or aims.

Learn more about designing from

brainly.com/question/1212088

#SPJ1

5 0
1 year ago
Other questions:
  • Write a program that determines the price of a movie ticket (similar to the one in the chapter). The program asks for the custom
    9·1 answer
  • Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
    14·1 answer
  • Which change signaled a musical progression toward rock and roll?
    14·1 answer
  • Write a memo to the vice president, outlining the steps an employee might have taken to create an e-mail message and make it app
    15·1 answer
  • What the benefit is of folder when working with files
    8·1 answer
  • (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle t
    6·1 answer
  • One condition for deadlocks is the circular-wait condition. One way to ensure that this condition never holds is to impose a tot
    12·2 answers
  • Billy used to take care of his laptop. However, one day he lost his laptop. He lost all his data, and there was no way to retrie
    11·1 answer
  • A deluxe meal, represented by a DeluxeMeal object, includes a side dish and a drink for an additional cost of $3. The DeluxeMeal
    14·1 answer
  • 4. Write technical term for the following statements
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!