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
miv72 [106K]
4 years ago
11

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

dit 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.#include using namespace std;int main() {const int NUM_VALS = 4;int testGrades[NUM_VALS];int i = 0;int sumExtra = -9999; // Assign sumExtra with 0 before your for looptestGrades[0] = 101;testGrades[1] = 83;testGrades[2] = 107;testGrades[3] = 90;/* Your solution goes here */cout << "sumExtra: " << sumExtra << endl;return 0;}

Computers and Technology
1 answer:
jeka57 [31]4 years ago
5 0

Answer:

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

     if (testGrades[i] > 100) {

        sumExtra += testGrades[i] - 100;      }   }                                      

Explanation:

The complete program is as follows:

#include<iostream>  

using namespace std;

int main()  

{const int NUM_VALS = 4;

int testGrades[NUM_VALS];

int i = 0;

int sumExtra = 0;

// Assign sumExtra with 0 before your for loop

testGrades[0] = 101;

testGrades[1] = 83;

testGrades[2] = 107;

testGrades[3] = 90;

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

     if (testGrades[i] > 100) {

        sumExtra += testGrades[i] - 100;      }   }        

cout << "sumExtra is: " << sumExtra << endl;

return 0;}

Lets see how the program works:

The value of NUM_VALS is 4 which is fixed throughout the program as const is used with the statement. testGrades is an array of size 4 as the value of NUM_VALS is 4. i is initialized to 0 and it is used as an index variable. The elements of testGrades[] array are 101 , 83, 107 and 90. The loop starts from 0 and continues to iterate until the value of i becomes less than NUM_VALS i.e. 4.

In the first iteration the value of i = 0 and it is positioned at element at 0-th index of testGrades array i.e. 101. Then the if statement checks if the element at i-th index ( 0 index) is greater than 100. This is true as 101 > 100. So sumExtra += testGrades[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 element at 1st index of testGrades array i.e. 83. Then the if statement checks if the element at i-th index ( 1 index) 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 element at 2nd index of testGrades array i.e. 107. Then the if statement checks if the element at i-th index ( 2 index) is greater than 100. This is true as 107 > 100. So sumExtra += testGrades[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 element at 3rd index of testGrades array i.e. 90. Then the if statement checks if the element at i-th index ( 3 index) 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.

The program along with the output is attached as the screen shot.

You might be interested in
a term to describe article that can be displayed in their entirety as opposed to abstract and reference only?​
Maurinko [17]

Answer:

would it be term and tequnique?

Explanation:

oooooooo

7 0
3 years ago
Now suppose there are four links between source and destination (three routers in the path between source and destination). Each
pychu [463]

Answer:

12.1 seconds

Explanation:

Step 1:

Assuming the following data :

N: Size of packet = 30 Mb

T: Transmission rate =  10 Mbps

C: Speed of light in copper = 2 * 10^8 m/s

L: Length of link 5000 km

Step 2:

Calculation of the Transmission delay and the Propagation Delay

Transmission delay = \frac{packet size}{bandwidth} = \frac{30Mb}{10Mbps} = 3s

Propagation delay = \frac{length of link}{speed of light in copper} = \frac{5000*10^3}{2 * 10^8} = 0.025s

Step 3:

Calculation of the end-to -end delay

The end-to-end delay = 4*(Transmission Delay+Propagation Delay) = 4*(3+0.025) = 12.1 seconds

6 0
4 years ago
How you will install an operating system on your computer
defon
Someone can install an operating system by disk or removable storage media.

Disk being floppy, tape or commonly a DVD.

Removable storage being a USBdrive.
5 0
3 years ago
¿En qué situaciones puedo utilizar formato condicional?
pshichka [43]

Answer:

El formato condicional es una herramienta útil para identificar patrones o tendencias en una hoja de cálculo. Por ejemplo, una regla podría ser: si el valor es mayor que 5.000, que la celda sea amarilla. Así, podrás ver de un vistazo las celdas cuyo valor es superior a 5.000. Puedes usarlo para describir graficas cientificas o Datos matematicos.

Explanation:

El formato condicional facilita el proceso de resaltar celdas o rangos de celdas interesantes, destacar valores inusuales y ver datos empleando barras de datos, escalas de colores y conjuntos de iconos que se correspondan con las variaciones específicas de los datos.

6 0
3 years ago
ravi met few peoples in a party and was mixing up well those wearing expensives clothing and fair complexion . which factors are
Lady_Fox [76]

The factor that influenced Ravi's perspective towards the people can be referred to as <u>Visual perspective.</u>

<u></u>

<h3>What do you mean by Visual perspective?</h3>

Visual perception or sight can be defined as the ability to interpret the encircling surroundings via photopic vision, color vision, scotopic vision, and mesopic vision, the usage of light withinside the visible spectrum meditated through items withinside the surroundings.

It also means the ability to see the world through others' perspectives, which takes into account what and how they see it.

Thus, The factor that influenced Ravi's perspective towards the people can be referred to as <u>Visual perspective.</u>

<u></u>

Learn more about Visual perspective:

brainly.com/question/14956318

#SPJ1

<u></u>

6 0
2 years ago
Other questions:
  • In Oracle, _____ make(s) it possible to merge SQL and traditional programming constructs, such as variables, conditional process
    5·1 answer
  • Describe a situation where it would be appropriate to use each of the six leadership styles described by Daniel Goleman
    7·1 answer
  • Write the 8-bit signed-magnitude, two's complement, and ones' complement representations for each decimal number: +25, + 120, +
    11·1 answer
  • What is wrong, logically, with the following code? if (x &gt; 10) System.out.println("Large"); else if (x &gt; 6 &amp;&amp; x &l
    11·1 answer
  • Which of the following statements is false?a.Unethical behavior is always illegal.b.Ethical decisions are usually influenced by
    12·1 answer
  • To use the Report Wizard to create a report for a query, select the query in the Navigation Pane, click ____ on the ribbon, and
    13·1 answer
  • A measuring cylinder is used to measure the volume of an irregular<br>solid object.​
    5·1 answer
  • How do you know when a spreadsheet object is active in a Word document?      A. The Ribbon is minimized. B. The Excel Formula ba
    10·2 answers
  • When an instruction is sent to the CPU in a binary pattern, how does the CPU know what instruction the pattern means
    7·1 answer
  • Which of the following is an example of a directory path? Check all of the boxes that apply.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!