Answer to Question #322753 in C++ for nickname

Question #322753

This program will calculate the average(%) of exam grades.

It will also add extra credit points to the exam average given the course difficulty.

Enter all of the grades for one student. Type (-1) when finished with that student.

If you have additional students, you will be prompted to repeat the program at the end.

 

Enter an exam grade (type -1 to quit):  [user types: 100]

Enter an exam grade (type -1 to quit):  [user types: 90]

Enter an exam grade (type -1 to quit):  [user types: 80]

Enter an exam grade (type -1 to quit):  [user types: -1]

 

Exam average, including extra credit, is: 93


1
Expert's answer
2022-04-03T07:59:50-0400
#include <iostream>
using namespace std;

int main() {
    char ch;
    int sum;
    int num;
    int grade;

    do {
        sum = 0;
        num = 0;
        grade = 0;

        while (true) {
            cout << "Enter an exam grade (type -1 to quit): ";
            cin >> grade;
            if (grade == -1) {
                break;
            }
            sum += grade;
            num++;
        }
        int extra_credit = 3;
        int avg = sum / num + extra_credit;
        
        cout << "Exam average, including extra credit, is: " << avg << endl;

        cout << endl << "Do you have additional students? ";
        cin >> ch;
    } while (ch == 'y' || ch == 'Y');

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS