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
svet-max [94.6K]
3 years ago
7

Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cr

edit is 100, so anything over 100 is extra credit. Ex: If testGrades = {101, 83, 107, 90}, then sumExtra = 8, because 1 + 0 + 7 + 0 is 8.

Computers and Technology
1 answer:
Anestetic [448]3 years ago
3 0

Answer:

Here is for loop that sets sumExtra to the total extra credit received. I am writing a program in C++

for(i = 0; i <= testGrades.size() - 1; i++){

  if(testGrades.at(i) > 100){

      sumExtra = sumExtra + (testGrades.at(i) - 100);   } }

Explanation:

The complete program is:

#include <iostream> //to use input output functions

#include <vector> //to use vectors

using namespace std; //to identify objects like cin cout

int main() { //start of main function

const int NUM_VALS = 4; // sets the value of NUM_VALS as a constant to 4

vector<int> testGrades(NUM_VALS); // initialize the vector of int (integer) type

int i = 0; // i is initialzed to 0

int sumExtra = 0; //stores the total extra credit

testGrades.at(0) = 101; //sets 101 at first position in vector

testGrades.at(1) = 83; //sets value 83 at second position

testGrades.at(2) = 107; //sets value 107 at third position

testGrades.at(3) = 90; //sets value 90 at fourth position

for(i = 0; i <= testGrades.size() -1; i++){ //loop iterate through each value of in a vector testGrades

  if(testGrades.at(i) > 100){ // if the value in a vector exceeds 100

      sumExtra = sumExtra + (testGrades.at(i) - 100);   } } //computes total extra credit

cout << "sumExtra: " << sumExtra << endl;} //displays the value of computed total extra credit in output

The loop works as follows:

In the first iteration the value of vector testGrades at(i) is at(0) = 101.

if statement checks if this value/element is greater than 100. This is true as 101 > 100. So sumExtra = sumExtra + (testGrades.at(i) - 100); statement is executed in which 100 is subtracted from that element and the result is added to the sumExtra. sumExtra is initialized to 0 so the value of sumExtra becomes: 0+ 101 - 100= 1 So the value of sumExtra = 1

In the second iteration the value of i = 1 and it is positioned at 2nd value of vector testGrades i.e. 83. Then if statement checks if this value/element is greater than 100. This is false as 83 < 100. So the value of sumExtra = 1

In the third iteration the value of i = 2 and it is positioned at 3rd value of vector testGrades i.e. 107. Then if statement checks if this value/element is greater than 100. This is true as 107 > 100.

sumExtra = sumExtra + (testGrades.at(i) - 100); statement is executed in which 100 is subtracted from that element and the result is added to the sumExtra

sumExtra is 1 so the value of sumExtra becomes: 1+ 107 - 100= 8 So the value of sumExtra = 8

In fourth iteration  the value of i = 3 and it is positioned at 4th value of testGrades vector i.e. 90. Then the if statement checks if this element is greater than 100. This is false as 90 < 100. So the value of sumExtra remains 8.  

Finally the loop breaks as the value of i becomes 4. So the output is 8.

You might be interested in
It is 10PM and you are inside in the middle of a large building. Your cell phone is dead so you cannot use wifi or cell signals
kupik [55]

<em>The answer is: your GPS unit cannot send signals to the satellite when it cannot reach it by line of sight. </em>

<em> </em>

<em>GPS signals are based on frequencies that can be blocked by solid objects (like walls and roofs). A GPS device is using a series of satellites to detect and see where it is physically located. These frequencies are sent from these plates (satellites) and we cannot expect it to go through all kinds of barriers. When you use a GPS inside a building, a wide variety of physical barriers and potential interference sources make it difficult for the device to detect your location accurately. </em>

<em> </em>

<em />

4 0
3 years ago
In approximately 50 words, describe the most common manufacturing systems and list some of the career opportunities in manufactu
Nezavi [6.7K]

Answer: SEE EXPLANATION

Explanation:

The manufacturing system refers to a collection of of procedures steps and processes involved in the creation of a desired product. Manufacturing systems include common which is the oldest and usually performed manually. The intermittent system which allows the production of more than one product from a single production line. The continuous system which favors massive production of a single product and the flexible system which offers enhanced technological mechanism to aid efficient production.

Careers in manufacturing include Quality Assurance, Machinist, steam and boiler technicians Food processing technologist among others.

6 0
3 years ago
if you play creative destruction and if u have a mic and if u play it 24/7 and would like to form a team tell me your name or yo
kipiarov [429]

i dont know that game but ill see if i like it and if i do ill send u my ID number ok


8 0
3 years ago
Describing Report Tools Functions
Shkiper50 [21]

Answer:

C. format

Explanation:

4 0
3 years ago
You can play a simple slide show in Windows Photo Viewer by clicking the ____ button in the playback controls.
Ludmilka [50]

Answer:

Photos is the correc answer for the above question.

Explanation:

  • Photo is an app that is available in the windows operating system. It facilitates the user to see the photos. It gives the facilities to click the slide button to view the picture like slides.
  • When any users want to use this app, then he needs to first install this app on the windows and then he can use this to see the photos like slides presentation.
  • The above question asks about the features which are used to view the pictures like slides. This app is known as "Photos".
7 0
3 years ago
Other questions:
  • Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being
    14·1 answer
  • Clifford created a table using OpenOffice Writer and entered some information into the table. Later, he needed to add more rows
    15·2 answers
  • The use of computers to combine data from multiple sources and create electronic dossiers of detailed information on individuals
    8·1 answer
  • Describe how computer is in the last 35 years
    6·1 answer
  • Is a fundamental building block of a relational database because this object stores all of the data
    15·1 answer
  • Write a program that does the following: • Alphabetizes a list of small (non-capital) letters. For consistency, make the string
    14·1 answer
  • The director of HR realizes that the KSAs currently used for hiring entry-level engineers are outdated. In order to establish wh
    5·1 answer
  • SLA:
    14·1 answer
  • Compare mini and mainframe computer in terms of speed,memory and storage​
    15·1 answer
  • Why does my smoke detector keep beeping even after i change the battery?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!