Today we run C++ programming to find out the grade of a student when the marks of 6 subjects are given.
The method of assigning grade is –
percentage>=85 grade=A
percentage<85 and percentage>=70 grade=B
percentage<70 and percentage>=55 grade=C
percentage<55 and percentage>=40 grade=D
percentage<40 grade=E
This c++ language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.
Find grade of a student according to their percentage in c++ programming
#include
using namespace std;
class test2 {
public:
double m1, m2, m3, m4, m5, m6;
string grade, name;
void Getgrade(double m1,double m2,double m3,double m4,double m5,double m6,string grade,string name) {
double pre, total;
//total Maarks of all subject
total = m1 + m2 + m3 + m4 + m5 + m6;
pre = total / 6;
if (pre > 33) {
if (pre >= 85) {
grade = “A”;
cout<
else if (pre >= 70) {
grade = “B”;
cout<
else if (pre >= 55) {
grade = “C”;
cout<
else if (pre >= 40) {
grade = “D”;
cout<
else {
grade = “E”;
cout<
}
else {
cout
}
}
int main(){
test2 o ;
cout<<“Please Enter the Student Name:”;
o.name = c.nextLine();
cout<<“enter all the marks of “<
cin>>o.m2;
cin>>o.m3;
cin>>o.m4;
cin>>o.m5;
cin>>o.m6;
o.Getgrade(o.m1,o.m2,o.m3,o.m4,o.m5,o.m6,o.grade,o.name);
}
Please Enter the Student Name:Abcd
enter all the marks of Abcd: 75
74
45
89
100
99
Abcd passed with B Grade and 80.33333333333333%
I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this c++ programming code or input & output please comment below
If you have another question about c++ programming send an email by contacting us form is given on the page right side.
Please share your experience about this post,
Thank You!