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
zhannawk [14.2K]
3 years ago
14

Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or negative, assign 0 to the elemen

t. Ex: lowerScores = {5, 0, 2, -3} becomes {4, 0, 1, 0}.Sample program:#include using namespace std;int main() { const int SCORES_SIZE = 4; vector lowerScores(SCORES_SIZE); int i = 0; lowerScores.at(0) = 5; lowerScores.at(1) = 0; lowerScores.at(2) = 2; lowerScores.at(3) = -3; for (i = 0; i < SCORES_SIZE; ++i) { cout << lowerScores.at(i) << " "; } cout << endl; return 0;}Below, do not type an entire program. Only type the portion indicated by the above instructions (and if a sample program is shown above, only type the portion.)
Computers and Technology
1 answer:
Verdich [7]3 years ago
8 0

Answer:

Replace <STUDENT CODE> with

for (i = 0; i < SCORES_SIZE; ++i) {

       if(lowerScores.at(i)<=0){

           lowerScores.at(i) = 0;

       }

       else{

           lowerScores.at(i) = lowerScores.at(i) - 1;

       }  

   }

Explanation:

To do this, we simply iterate through the vector.

For each item in the vector, we run a check if it is less than 1 (i.e. 0 or negative).

If yes, the vector item is set to 0

If otherwise, 1 is subtracted from that vector item

This line iterates through the vector

for (i = 0; i < SCORES_SIZE; ++i) {

This checks if vector item is less than 1

       if(lowerScores.at(i)<1){

If yes, the vector item is set to 0

           lowerScores.at(i) = 0;

       }

       else{

If otherwise, 1 is subtracted from the vector item

           lowerScores.at(i) = lowerScores.at(i) - 1;

       }  

   }

Also, include the following at the beginning of the program:

<em>#include <vector></em>

You might be interested in
How to change a documents theme colors in word?
VladimirAG [237]

Answer:

Change the theme colors in Word

1. Select Design > Colors.

2. Point to a color to preview how it will look in your document.

3. Select a color scheme.

Explanation:

7 0
3 years ago
A computer that delivers requested web pages to your computer or mobile device is a(n) _____.
yaroslaw [1]

Answer:

Web Server

A web server is server software, or hardware dedicated to running this software, that can satisfy client requests on the World Wide Web. A web server can, in general, contain one or more websites. A web server processes incoming network requests over HTTP and several other related protocols.

6 0
3 years ago
Specification of database requirements falls under which category of database​ administration?
enot [183]
Specification of database requirements falls under which category of database​ administration?

b. development
3 0
3 years ago
Assume that the final grade for a course is determined based on this scale - A: 900 points, B: 800-899 points, C: 700-799 points
saul85 [17]

Answer:

In Python:

def get_letter_grade(points):

   if points>=900:

       grade ="A"

   elif points>=800 and points < 900:

       grade ="B"

   elif points>=700 and points < 800:

       grade ="C"

   elif points>=600 and points < 700:

       grade ="D"

   else:

       grade = "F"

   return grade

Explanation:

This defines the function

def get_letter_grade(points):

The following if-else if conditions check the score to determine the appropriate grade

<em>    if points>=900:</em>

<em>        grade ="A"</em>

<em>    elif points>=800 and points < 900:</em>

<em>        grade ="B"</em>

<em>    elif points>=700 and points < 800:</em>

<em>        grade ="C"</em>

<em>    elif points>=600 and points < 700:</em>

<em>        grade ="D"</em>

<em>    else:</em>

<em>        grade = "F"</em>

This returns the grade

   return grade

5 0
2 years ago
Which of the following remote access security technologies performs authentication through a three-way handshake (that is, chall
levacccp [35]

Answer:

CHAP

Explanation:

CHAP allows a client to be authenticated without sending credential information across a network.

7 0
3 years ago
Other questions:
  • In this scenario, two friends are eating dinner at a restaurant. The bill comes in the amount of 47.28 dollars. The friends deci
    7·2 answers
  • What is the first step in the exchange between a web browser and a database?
    7·1 answer
  • why is wrong timing, poor technology, bad implementation and politics in business affected the OSI model as a standard
    5·1 answer
  • If you want to wrap text so that it fits a particular cell size, which formatting section would you use?
    9·2 answers
  • Who needs to be involved when assembling business solutions that include hardware and software?
    11·2 answers
  • A(n) ________ is a special value that cannot be mistaken as a member of a list of data items and signals that there are no more
    9·1 answer
  • "What technology will examine the current state of a network device before allowing it can to connect to the network and force a
    6·1 answer
  • Define Based Assessment ​
    5·1 answer
  • Explain the three schemes via which the binding of instructions and data to memory addresses can be done. In each scheme, how th
    13·1 answer
  • Question 1
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!