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
Alisiya [41]
3 years ago
10

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: matchValue: 2, userValues: {2, 1, 2, 2} (as in the example program above) matchValue: 0, userValues: {0, 0, 0, 0} matchValue: 10, userValues: {20, 50, 70, 100} (Notes)
Engineering
1 answer:
erica [24]3 years ago
6 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
A flow rate sensing device used on a liquid transport pipeline functions as follows. The device provides a 5-bit output where al
marysya [2.9K]

Answer:

Explanation:

The step by step analysis is as shown in the attached files.

8 0
3 years ago
Which of the following is most useful for doing research?
Ghella [55]

Answer:

Web Browser

Explanation:

Because you dont use a messaging app or presentation software to look up stuff its common knowledge

7 0
3 years ago
Diffusion of Ammonia in an Aqueous Solution Ammonia (A)-water (B) solution ta 278 K and 4 mm thick is in contact with an organic
Tom [10]

Answer:

Explanation:

The pictures below shows the whole explanation for the problem

4 0
4 years ago
You hang a heavy ball with a mass of 42 kg from a silver rod 2.7 m long by 1.9 mm by 2.6 mm. You measure the stretch of the rod,
nadezda [96]

Answer:

Explanation:

cross sectional area  A = 1.9 x 2.6 x 10⁻⁶ m²

= 4.94 x 10⁻⁶ m²

stress = 42 x 9.8 / 4.94 x 10⁻⁶

= 83.32 x 10⁶ N/m²

strain = .002902 / 2.7

= 1.075 x 10⁻³

Young's modulus = stress / strain

= 83.32 x 10⁶ / 1.075 x 10⁻³

= 77.5 x 10⁹ N/m²

5 0
3 years ago
Question 4 (1 point) Sophia is working in her garden. She made two trips with her wagon along the same path to haul supplies. Th
yaroslaw [1]

Answer:

Option A

Explanation:

Please find the attachment

4 0
3 years ago
Other questions:
  • Superheated steam is stored in a large tank at 6 MPa and 800°C, The steam is exhausted isentropically through a converging-diver
    5·1 answer
  • How can endurance athletes best delay muscle fatigue during training? a. By avoiding sports drinks during exercise b. By eating
    6·2 answers
  • The coefficient of performance of a reversible refrigeration cycle is always (a) greater than, (b) less than, (c) equal to the c
    12·1 answer
  • For an Otto cycle, plot the cycle efficiency as a function of compression ratio from 4 to 16.
    14·1 answer
  • On a cold winter day, wind at 55 km/hr is blowing parallel to a 4-m high and 10-m long wall of a house. If the air outside is at
    8·1 answer
  • 9. What is a whip check?
    12·1 answer
  • A student lives in an apartment with a floor area of 60 m2 and ceiling height of 1.8 m. The apartment has a fresh (outdoor) air
    14·1 answer
  • Which is equal to a temperature of 50°F?<br><br> 18°C<br> 46°C<br> 10°C<br> 32°C
    13·2 answers
  • Pay attention to the following questions!
    14·1 answer
  • determine the position d of the 6- kn load so that the average normal stress in each rod is the same.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!