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
Binary divide 1101011 by 111​
denis-greek [22]

is this computer subject

5 0
3 years ago
Read 2 more answers
Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, conve
juin [17]

Answer:

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

   double num1, num2, num3, num4, num5, sum = 0;

   cout << "Input: ";

   cin >> num1 >> num2 >> num3 >> num4 >> num5;

   

   sum = num1 + num2 + num3 + num4 + num5;

   cout << "Output: " << static_cast<int>(round(sum)) << endl;

   return 0;

}

Explanation:

Include cmath to use the round function

Declare the variables

Get the five numbers from the user

Sum them and assign the result to the sum

Round the sum using the round function, and convert the sum to an integer using static_cast statement

Print the sum

6 0
4 years ago
How do the following technologies help you with your quest to become a digital citizen kiosks enterprise computing, natural lang
Dafna11 [192]

Answer:

How could be an individual become a digital citizens?

Skills such as self-advocacy, conflict resolution, anger management, and decision-making skills, as well as the ability to use assertiveness, resistance, and refusal techniques, are also included and can help students respond safely and effectively online

Explanation:

SAlamat po pa rate nalang

5 0
2 years ago
Which actions should be taken so that transitions proceed automatically? Check all that apply.
DiKsa [7]

Answer:

a,d

Explanation:

because when you the after box you will probably see it,and you got put effects to the transition

6 0
4 years ago
Read 2 more answers
What is Celeste? ( This is for my coding class )
cricket20 [7]

Answer:

Set on a fictional version of Mount Celeste, it follows a young woman named Madeline who attempts to climb the mountain, and must face her inner demons in her quest to reach the summit.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • You create hidden form fields with the ____ element.
    9·1 answer
  • The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula:
    15·1 answer
  • Someone hacked into an employees computer and erased all of their data. All data for the past three weeks was lost as that was w
    11·2 answers
  • PLZ ANSWER THESE QUESTIONS FOR 30 POINTS AND BRAINLIEST!
    9·1 answer
  • 2 of 10
    11·1 answer
  • Which two statements are true about algorithms?
    15·2 answers
  • Select the correct answer.
    5·2 answers
  • How was kapilvastu named​
    11·1 answer
  • Need help with these plss correct answers
    13·1 answer
  • What is the descriptor for a filter that warns or blocks you from potentially fraudulent or suspicious websites?.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!