-
Notifications
You must be signed in to change notification settings - Fork 0
/
student
50 lines (47 loc) · 1011 Bytes
/
student
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
#include <iostream>
using namespace std;
class Student
{
private:
int roll;
string name;
int mathMasks;
int phyMasks;
int chemMasks;
public:
Student(int r, string name, int m, int p, int c) {
roll = r;
this->name = name;
mathMasks = m;
phyMasks = p;
chemMasks = c;
}
int total() {
return mathMasks + phyMasks + chemMasks;
}
char grade() {
float average = total()/3;
if ( average > 60 ) return 'A';
else if ( average > 40 ) return 'B';
else return 'C';
}
~Student(){};
};
void main() {
int roll;
string name;
int m, p, c;
cout << "Enter the roll number "
cin >> roll;
cout << "Enter the student name "
cin >> name;
cout << "Enter the math score "
cin >> m;
cout << "Enter the physics score "
cin >> p;
cout << "Enther the chemics score "
cin >> c;
Student s(roll, name, m, p, c);
cout << "The total score of this student is " << s.total() << endl;
cout << "The grade of this student is " << s.grade() << endl;
}