-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudentClass.cpp
51 lines (47 loc) · 1.09 KB
/
studentClass.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
#include <iostream>
using namespace std;
class Student{
private:
int rollNumber;
string name;
int maths;
int science;
int social;
public:
Student(int rollNumber, string name, int maths, int science, int social);
int totalMarks();
char grade();
void dummy(){
cout<<this<<endl;
}
};
Student::Student(int rollNumber, string name, int maths, int science, int social){
this->rollNumber = rollNumber;
this->name = name;
this->maths = maths;
this->science = science;
this->social = social;
}
int Student::totalMarks(){
return maths+science+social;
}
char Student::grade(){
char grade;
int totalMarks = Student::totalMarks();
int average = totalMarks / 3;
if (average > 60)
grade = 'P';
else
grade = 'F';
return grade;
}
int main(){
Student mano(21, "Mano", 98,94,100);
cout<<mano.grade()<<endl;
cout<<&mano<<endl;
mano.dummy();
Student mikasa(32,"Mikasa", 32,46,57);
cout<<&mikasa<<endl;
mikasa.dummy();
return 0;
}