-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstudent.cpp
More file actions
49 lines (48 loc) · 743 Bytes
/
student.cpp
File metadata and controls
49 lines (48 loc) · 743 Bytes
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
#include<bits/stdc++.h>
using namespace std;
class Student
{
private:
int roll;
string name;
int mathMarks;
int phyMarks;
int chemMarks;
public:
Student(int r,string n,int m,int p,int c)
{
roll=r;
name=n;
mathMarks=m;
phyMarks=p;
chemMarks=c;
}
int total()
{
return mathMarks+phyMarks+chemMarks;
}
char grade()
{
float average=total()/3;
if(average > 60)
return 'A';
else if(average>=40 && average<60)
return 'B';
else
return 'C';}
};
int main()
{
int roll;
string name;
int m,p,c;
cout<<"Enter Roll number of a Student: ";
cin>>roll;
cout<<"Enter Name of a Student:";
cin>>name;
cout<<"Enter marks in 3 subjects";
cin>>m>>p>>c;
Student s(roll,name,m,p,c);
cout<<"Total Marks:"<<s.total()<<endl;
cout<<"Grade of Student:"<<s.grade()<<endl;
}