-
Notifications
You must be signed in to change notification settings - Fork 0
/
studentdetailsusingclasses.cpp
72 lines (67 loc) 路 1.45 KB
/
studentdetailsusingclasses.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//Program to store student details in classes
#include<iostream>
#include<string>
using namespace std;
class Student
{
private:
int roll;
string name;
string dob;
string addr;
int mat;
int phy;
int chem;
int cs;
int eng;
int hin;
public:
Student(int r, string n, string d, string a, int m, int p, int c, int cs, int e, int h)
{
roll=r;
name=n;
dob=d;
addr=a;
mat=m;
phy=p;
chem=c;
cs=cs;
eng=e;
hin=h;
}
int total()
{
return (mat+phy+chem+cs+eng+hin);
}
float percentage()
{
int sum=total();
float perc=sum/6;
return perc;
}
};
int main()
{
int n,r,m,p,c,cs,e,h;
string nam,d,ad;
cout<<"\nEnter the no. of students: ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"\n\n\n-----#"<<i+1<<"-----";
cout<<"\nEnter the Roll: ";
cin>>r;
cout<<"\nEnter the Name: ";
getline(cin,nam);
cout<<"\nEnter the Date of Birth (dd/mm/yyyy): ";
getline(cin,d);
cout<<"\nEnter the Address: ";
getline(cin,ad);
cout<<"\nEnter the marks in Maths, Physics, Chemistry, C.S, English Hindi: ";
cin>>m>>p>>c>>cs>>e>>h;
Student s[i](r,nam,d,ad,m,p,c,cs,e,h);
cout<<"\n\nThe total marks scored by the student is: "<<s[i].total();
cout<<"\nThe Percentage: "<<s[i].percentage();
}
return 0;
}