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
#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;
}
Comments
Leave a comment