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
kolbaska11 [484]
3 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.
Computers and Technology
1 answer:
Tresset [83]3 years ago
5 0

Answer: The program in c++ language for the given scenario is given below.

#include <iostream>

using namespace std;

int main() {    

int sumExtra = 0, len;

int testGrades[len];

// this input determines the length of the array

cout<<"Enter the number of grades to be entered : ";

cin>>len;

 

for(int j=0; j<len; j++)

{

    cout<<endl<<"Enter grade "<<j+1;

    cin >> testGrades[j];

}

 

for(int i=0; i<len; i++)

{

    if(testGrades[i] > 100)

        sumExtra =  sumExtra + ( testGrades[i] - 100 );

    else

        continue;

}

cout<<endl<<"Sum of extra credit = " << sumExtra;

return 0;

}

Explanation:

Header files are imported for input/ output alongwith the namespace.

#include <iostream>

using namespace std;

All variables and array is declared of type integer.

int sumExtra = 0, len;

int testGrades[len];

User is prompted for the number of grades to be entered. This number is stored in variable len, which determines the length of the array, testGrades.

testGrades[len];

Using for loop, grades are entered for each index.

for(int j=0; j<len; j++)

{

     cout<<endl<<"Enter grade "<<j+1;

     cin >> testGrades[j];

}

Using another for loop and if-else statement, if the grade > 100, extra credit is added and sum is stored in the variable, sumExtra.

for(int i=0; i<len; i++)

{

     if(testGrades[i] > 100)

          sumExtra =  sumExtra + ( testGrades[i] - 100 );

     else

          continue;

}

This is followed by displaying the message with sum of the extra credit.

The main() function has the return type int. Hence, integer 0 is returned at the end of the program.

In the above, endl keyword is used to insert break line. The following message will be displayed on the new line. This is another alternative for the newline character, \n.

The given program does not implements a class since the logic is simple. Also, the question does not specify that the class and object should be used.

You might be interested in
When a field is declared static there will be ________. Group of answer choices two reference copies of the field for each metho
anygoal [31]

Answer: one field copy gets generated in memory

Explanation:

When a field is declared static,it will become common for entire class instances. Single copy of field that gets created for the particular class where numerous instances present in that class can use it by sharing .

  • Other options are incorrect because  two copy of reference does not gets created as it only supports single copy.
  • Copy of the field for every class is not generated by static field.All method and instances use  only one field copy for the whole class.
  • Thus the correct answer is creation of only one field copy in memory for static field.

7 0
3 years ago
After you save a table, the new table name appears ____.
kobusy [5.1K]
Table1/2.....hope it helps
5 0
3 years ago
Read 2 more answers
What does it mean to “declare a variable”? create a variable use a variable share a variable modify a variable
lara [203]

You are defining the variable

6 0
3 years ago
Read 2 more answers
A technician is troubleshooting a small network with cable Internet service in which a user is receiving a message in her web br
Irina-Kira [14]

Answer:

True

Explanation:

The technician should first connect a computer directly to the cable modem and attempt to access the Internet, in order to ascertain the message been displayed on the screen. From there, he would know what to do to resolve the issue.

3 0
3 years ago
To remove an embedded chart, you should _____ it and press the DELETE key. (Points : 2) move drag hide click
Readme [11.4K]
I think the answer would be "click" 
3 0
3 years ago
Other questions:
  • Which feature is a component of a database application?
    7·1 answer
  • ................njkkjjiooiuuuu
    6·1 answer
  • Which group on the Home Ribbon allows you to add shapes to a PowerPoint slide?
    10·2 answers
  • Write the definition of a function named rotate4ints that is passed four int variables. The function returns nothing but rotates
    9·1 answer
  • Explain how signal detection theory can be used to analyze web site reading and searching. Based on this analysis, provide three
    14·1 answer
  • A tiny spot on an LCD monitor display screen that permanently remains black when it should be activated and displaying color is
    12·1 answer
  • When is the kids choiceee awads?????????????????????????
    12·2 answers
  • What does XD mean? I keep seeing people say it and I dont know what it means
    6·2 answers
  • Which of the following is a method which can be used to delete a page from a publication?
    6·1 answer
  • Write a program to find all integer solutions to the equation 4x + 3y -9z = 5 for values of x, y, and z between 0 to 100.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!