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
madreJ [45]
3 years ago
15

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}
#include
#include
using namespace std;
int main() {
const int NUM_VALS = 4;
int matchValue;
unsigned int i;
int numMatches = -99; // Assign numMatches with 0 before your for loop
vector userValues(NUM_VALS);
cin >> matchValue;
for (i = 0; i < userValues.size(); ++i) {
cin >> userValues.at(i);
}
/* Your solution goes here */
cout << "matchValue: " << matchValue << ", numMatches: " << numMatches << endl;
return 0;
}
Computers and Technology
1 answer:
Sedbober [7]3 years ago
3 0

Answer:

Replace /* Your solution goes here */ with:

cin>>matchValue;

numMatches = 0;

for (i = 0; i < userValues.size(); ++i) {

if(matchValue == userValues.at(i))

{

numMatches++;

}

}

Explanation:

This line gets input for matchValue

<em>cin>>matchValue; </em>

This line initializes numMatches to 0

<em>numMatches = 0; </em>

The following iteration checks for the number of matches (numMatches) of the matchValue

<em>for (i = 0; i < userValues.size(); ++i) { </em>

<em>if(matchValue == userValues.at(i)) </em>

<em>{ </em>

<em> numMatches++; </em>

<em>} </em>

<em>} </em>

<em>See Attachment for full source code</em>

Download cpp
You might be interested in
The design strategy that starts with a global view of the entire problem and breaks the problem down into smaller, more manageab
In-s [12.5K]

Answer:

Top down design

Explanation:

Top-down design is an approach that is used to break down the problem into the smaller subpart so that it can be manageable into more clear form.

C programming is the example of a top-down approach while C++ is the example of the bottom-up approach.

The advantages of the top-down design approach are:

1) easy to manage

2) easy to find the error

3) easy to debug

4 0
3 years ago
Recall that with the CSMA/CD protocol, the adapter waits K. 512 bit times after a collision, where K is drawn randomly. a. For f
julia-pushkina [17]

Complete Question:

Recall that with the CSMA/CD protocol, the adapter waits K. 512 bit times after a collision, where K is drawn randomly. a. For first collision, if K=100, how long does the adapter wait until sensing the channel again for a 1 Mbps broadcast channel? For a 10 Mbps broadcast channel?

Answer:

a) 51.2 msec.  b) 5.12 msec

Explanation:

If K=100, the time that the adapter must wait until sensing a channel after detecting a first collision, is given by the following expression:

  • Tw = K*512* bit time

The bit time, is just the inverse of the channel bandwidh, expressed in bits per second, so for the two instances posed by the question, we have:

a) BW  = 1 Mbps = 10⁶ bps

⇒ Tw = 100*512*(1/10⁶) bps = 51.2*10⁻³ sec. = 51.2 msec

b) BW = 10 Mbps = 10⁷ bps

⇒ Tw = 100*512*(1/10⁷) bps = 5.12*10⁻³ sec. = 5.12 msec

5 0
3 years ago
Type the correct answer in the box. Spell the words correctly.
ExtremeBDS [4]

Answer:

The IT field yeah am sure

7 0
3 years ago
If your computers normal zoom is 100, but it looks like its at 500, how do you stop that? my invisioned thing isn't on, neither
Alex Ar [27]

Answer:

You just need to click over the desktop, move to the View, and then change to medium, if its the icon size.

However, if you feel your resolution requires screwing up, then you are required to do the right-click, and again over the Desktop and then move to the settings (screen resolution),

And if you by chance clicked on the magnifier utility, you can CTRL + ALT +DEL and you will also be required to shut the interface.

Explanation:

You just need to click over the desktop, move to the View, and then change to medium, if its the icon size.

However, if you feel your resolution requires screwing up, then you are required to do the right-click, and again over the Desktop and then move to the settings (screen resolution),

And if you by chance clicked on the magnifier utility, you can CTRL + ALT +DEL and you will also be required to shut the interface.

7 0
3 years ago
PYTHON --- Toll roads have different fees based on the time of day and on weekends. Write a function calc_toll() that has three
Oduvanchick [21]

The toll program illustrates the use of conditional statements;

As a general rule, conditional statements are used to make decisions

<h3>The toll program</h3>

The toll program written in Python where conditional statements are used to make several decisions is as follows:

def calc_toll(hour, morning, weekend):

   toll_fee = 0

   if weekend == False:

       if morning == True:

           if hour < 7:

               toll_fee+=1.15

           elif hour < 10:

               toll_fee+=2.95

           elif hour <= 12:

               toll_fee+=1.90

       else:

           if hour < 3:

               toll_fee+=1.90

           elif hour < 8:

               toll_fee+=3.95

           elif hour >= 8:

               toll_fee+=1.40

   else:

       if morning == True:

           if hour < 7:

               toll_fee+=1.05

           elif hour <= 12:

               toll_fee+=2.15

       else:

           if hour < 8:

               toll_fee+=2.15

           elif hour >= 8:

               toll_fee+=1.10

   return toll_fee

   

Read more about conditional statements at:

brainly.com/question/24833629

#SPJ1

3 0
2 years ago
Other questions:
  • Is Apple a consumer or luxury brand? Give examples.
    10·1 answer
  • Frank is a writer. He needs to work for long hours and type for long periods on the computer. What injury can Frank develop?
    15·2 answers
  • Which network is the predecessor of the Internet?
    13·1 answer
  • How do I copy and paste equations and pictures like math graphs, to post on this site to help get my questions answered?
    13·2 answers
  • What are the three types of programming design?
    15·1 answer
  • I'm looking for a new laptop for school. Which laptop would be the best. Right now I have a chromebook and it is broken. 
    12·2 answers
  • g A sign of thrashing is Group of answer choices the CPU utilization increases as the degree of multiprogramming is increased. t
    5·1 answer
  • Digital signatures are as legally acceptable as written signatures.
    12·1 answer
  • The structure of the atmosphere based temperature changes ​
    5·1 answer
  • An additional factor in how an element is rendered is that properties are passed from a parent element to its children in a proc
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!