-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade_class_.cpp
52 lines (45 loc) · 1.05 KB
/
grade_class_.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
using namespace std;
class student
{
private:
int roll,maths, comp, eng;
string name;
public:
student(int r, string n, int m, int c, int e);
inline int total();
char grade(){
float avg = total() / 3;
if (avg > 60)
return 'A';
else if (avg < 60 && avg >=40)
return 'B';
else
return 'C';
}
};
int main(){
int roll;
string name;
int m, c, e;
cout << "Enter Roll : ";
cin >> roll;
cout << "Name of student : ";
cin >> name;
cout << "Marks in 3 subjects : ";
cin >> m>>c>>e;
student stud(roll, name, m, c, e);
cout<<"Total marks: "<<stud.total()<<endl;
cout << "Grade for student: " << stud.grade() << endl;
}
student :: student (int r, string n,int m, int c, int e)
{
roll = r;
name = n;
maths = m;
comp = c;
eng = e;
}
int student ::total(){
return (maths + comp + eng);
}