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
Compose an e-mail to your coworker Adam that describes how to add a photograph to a slide.
pantera1 [17]

The ways to add a photograph to a slide is given below: What to write when composing the email is also given below.

<h3>How do you Insert photos into a slide?</h3>

The steps are given below?\

  • The first thing to do is to open  the slide you want to insert the image on.
  • then click on Insert menu, and take the cursor to the Picture, and then one can click Photo Browser or insert pictures.
  • Then select the picture that you want and and one can drag it onto the slide.

Note that it is essential to follow the steps and one can add as many pictures as they want to their slides.

Learn more about e-mail from

brainly.com/question/24506250

#SPJ1

3 0
2 years ago
Robert and Anne, a married couple filing jointly, have an adjusted gross income of $68,676. They claim two exemptions, and can d
artcher [175]

Answer:

the answer is B

Explanation:

Just took the test

8 0
2 years ago
Read 2 more answers
You need to create the directory /var/oracle/database/9i. only the directory /var currently exists. from the root of the filesys
egoroff_w [7]
To create a directory, you can use the command mkdir. Below is an example:

mkdir /var/oracle/database/9i
3 0
3 years ago
If the numbers on the spring scales read 200 g. What property of the shoes is being measured?
lianna [129]
Pretty sure its mass
5 0
3 years ago
What the difference between Swipe and slide.<br>​
Sunny_sXe [5.5K]

Explanation:

The best example of a slider as you have mentioned is a volume control. it is defined as "move smoothly along a surface while maintaining continuous contact with it." Whereas the swiping action is defined as "hit or try to hit with a swinging blow."

7 0
3 years ago
Other questions:
  • Most students overestimate their skill level and abilities to take open book tests.
    11·2 answers
  • What is the biggest type of gear?<br><br>A. Spur<br>B.Worm<br>C.Wheel<br>D.Pinion
    6·2 answers
  • One of the newest electronic conveniences is the ________, which can serve as a credit card, a debit card, and even unlock doors
    12·1 answer
  • Please help me with question 1!
    8·2 answers
  • Design a software system for a bookstore that keeps an inventory of two types of books: Traditional books and books on CD. Books
    12·1 answer
  • Case Study/Scenario: First, Julio clicks Tools from the Chrome menu on the toolbar. Next, he looks for Manage Add-Ons but can no
    9·1 answer
  • Drag the tiles to the correct boxes to complete the pairs. Match the conversion systems with their steps. To convert a decimal f
    8·1 answer
  • Make the list of menu icon in MS Excel<br>​
    8·1 answer
  • Ethan wants to change the font in his document. He should _____.
    8·1 answer
  • 6. kinukuha nito ang kabuuang bilang ng mga numerical na datos sa mga piniling cells
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!