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
A leading global vendor of computer software, hardware for computer, mobile and gaming systems, and
V125BC [204]

Answer:

Microsoft

Explanation:

5 0
2 years ago
Which of the following is not a benefit of shaping data with the Power Query Editor?
algol13

Answer:

A

Explanation:

I am not 100% sure but without the shaping data, data can still be merged from multiple sources.

3 0
2 years ago
Which phrase best describes a scenario in Excel 2016?
Airida [17]

Answer:

what are the phrases?

Explanation:

6 0
3 years ago
Which type of memory helps in reading as well as writing data?
Anuta_ua [19.1K]

The read-write type of memory helps in reading as well as writing data. This computer memory is used by users to continually update the data (to access (read from) or alter (write to) ) that is held on hardware storage devices. Internal or external hard disk drives, rewritable CDs or small flash drives can be all physical setups of read-write memory.

6 0
2 years ago
This is tech question related to mobile and PC.
love history [14]

I am guessing the bluetooth process is same as usb proccess. So when i transfered a video via usb and took out the usb (for apple phone), there <u>was</u> a file but when i clicked it it said that the phone isn't plugged in

4 0
3 years ago
Other questions:
  • A program to add two numbers in C++
    15·1 answer
  • Design a new Triangle class that extends the abstract
    13·1 answer
  • Using the mouse to move or copy cells is called ____.
    15·1 answer
  • a paragraph is a segment of text with the same format that begins when you press the enter key and ends when you press enter key
    6·2 answers
  • Which of the following is the code of acceptable behaviors users should follow while on the Internet; that is, it is the conduct
    15·1 answer
  • Why has base 2 been accepted and used as the basis for computing?​
    8·1 answer
  • How does the autosum command calculate data? Need help ASAP​
    5·1 answer
  • Is it true that if the user log out the computer will turn off automatically​
    9·2 answers
  • A manager suspects that one of his team members has been fraudulently accessing confidential and sensitive information and breac
    8·2 answers
  • Self-driving cars are a result of developments in which field of computer<br> science?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!