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
Pls answer asap do not use internet
kozerog [31]

Answer:

key differences between linux and windows operating system linux is free and open resource whereas windows is a commercial operating system whose source code is inaccessible windows is not customizable as against linux is customizable and a user can modify the code and can change it looks and feels

Explanation:

I hope this helps

5 0
3 years ago
Suppose you have a class called Child with an instance data value called weight and height. Then it has a method called doubleWe
alexira [117]

Answer:

Explanation:

The following code is written in Java. I recreated the entire Child class as described with the instance variables and the doubleWeight method. Then created the getter and setter methods for both the weight and height variables.

class Child {

   double weight, height;

   public double doubleWeight() {

       double superWeight = weight * height;

       return superWeight;

   }

   public double getWeight() {

       return weight;

   }

   public void setWeight(double weight) {

       this.weight = weight;

   }

   public double getHeight() {

       return height;

   }

   public void setHeight(double height) {

       this.height = height;

   }

}

7 0
2 years ago
How do you add text to a blank slide layout?
melisa1 [442]

The answer is B; Draw a text box and enter text

By default, we add text to a PowerPoint slide by typing it directly into a placeholder. However, you can use a text box to enter text into a blank slide or outside the placeholders. To add text on a blank slide click on the insert menu and select the Text box option. Click and hold down your mouse button while you drag the mouse. You will then clink inside the text box and starting typing.


6 0
3 years ago
Read 2 more answers
How to get a javascript's varible
Kamila [148]

Answer:

If you want to use a js variable in a php script you MUST pass it within a HTTP request. There are basically two ways: Submitting or reloading the page.

Explanation:

In programming, just like in algebra, we use variables in expressions (total = price1 + price2). From the example above, you can calculate the total to be 11. JavaScript variables are containers for storing data values. All JavaScript variables must be identified with unique names. These unique names are called identifiers.

8 0
2 years ago
A technician wants to configure the inbound port of a router to prevent FTP traffic from leaving the LAN.
Archy [21]

Answer:

The technician will want to add ACL for ports 20 and 21

Explanation:

The FTP protocol by default will attempt to use 21 for TCP access and 20 for data access.  By enabling an Access Control List (ACL) on ports 20 and 21, the technician can prevent FTP traffic from leaving the network on the default ports.

Cheers.

8 0
3 years ago
Other questions:
  • A(n) ____ loop executes a predetermined number of times.
    12·1 answer
  • How can you find Web pages that contain news published during the past week?
    8·1 answer
  • .in the array based list implementation of the ADT what is the worst case time efficiency of the getEntry method?
    14·1 answer
  • Why do we need vram​
    6·1 answer
  • Select the answer that best describes the activity
    5·2 answers
  • Which of the following feature are parts of Toyota’s safety system?
    10·1 answer
  • -Convert the 1's complement 10111010 to decimal
    15·2 answers
  • Describe the difference between a myth and a fable.
    12·1 answer
  • List and explain three computing devices from the 20th century​
    13·2 answers
  • You have been asked to analyze the Excel data provided by your IT department. You would like to have the ability to sort and fil
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!