Write a C++ program that inputs the number of students in a class and the number of tests and the grades of the tests conducted by each student, then it calculates the average of the student and outputs related information as given below. The Average of a student is calculated considering the grades the student obtained in her/his tests divided by the number of tests the student conducted. A student should at least attend two out of the three tests of the course. For every student in the class the program should output, Student Name, student ID, Number of conducted Tests by the student, grades of conducted tests, average of conducted tests, and a message as shown in the below table depending on the calculated average of the student. In addition, the program should calculate and output the average of the whole class.

Average Grade Message to output between 90 and less than or equals 100 Excellent Between 80 and less than 90 Good Between 70 and less than 80 oK Between 60 and less than 70 Weak Less than 60 Fail

5 Months
Discussion Span
Last Post by JamesCherrill
using namespace std;
int main()

int a,b,c,d,f,grade,score;
cout<<"enter your score";
if (score>=70&&score<=100)
cout<<a<<"you scored 70 and above:your grade is A"<<endl;
else if(score>=60&&score<=69)
cout<<b<<"your score is within 60 to 69:your grade is B"<<endl;
else if(score>=50&&score<=59)
cout<<c<<"your score is between 50 to 59: your grade is C"<<endl;
else if(score>=45&&score<=49)
cout<<c<<"your score is between 40 to 49: your grade is D"<<endl;
else if(score>=0&&score<=44)
cout<<c<<"your score is between 0 to 44: your grade is F"<<endl;
cout<<"your score is out of range";
return 0;

Edited by Reverend Jim: Corrected code formatting


That code is a good demo of how not to format code, but in various ways it's NOT a solution the requirement that was posted.
Was it intended as a sort of example of how to approach it (in which case that's better)?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.