-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaa.cpp
154 lines (141 loc) · 3.59 KB
/
aa.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*Assignment 2
Chaitanya Nitin Pawar
SE_B_48
Problem statement: Develop a program in c++ to create a database of student's information system containing the following information: Name, Roll no, class, division, date of birth, blood group, contact address, telephone number, driving license no. and other. Construct the database with suitable member functions. Make use of constructor, default constructor, copy constructor, destructor, static member function, friend class, this pointer, inline code and dynamic memory allocation operator new and delete as well as exception handling
*/
#include <iostream>
#include <string>
using namespace std;
class student
{
private:
string name, DoB, blood_grp, addr, year_class, mob;
int div;
int *rollno; //declaration of pointer
public:
friend class faculty; //faculty class is friend of student class
//default constructor
student()
{ rollno = new int; //reserve single location for rollno
*rollno = div = -1;
name = blood_grp = DoB = addr = year_class = mob = "";
}
// destructor
~student()
{
deleterollno; //deallocation of rollno
}
//function to add information in student database
voidadd_data()
{
cout<< "\n Enter Student Information: ";
cout<< "\n Enter Name: "<<endl;
cin.ignore(); //to clear input buffer
getline(cin,name);
cout<< "Enter Roll_no:";
cin>> *rollno;
cout<< "Enter Year(SE/TE/BE):";
cin>>year_class;
cout<< "Enter Division (1/2/3/4/5):";
cin>> div;
cout<< "Enter DoB: ";
cin>>DoB;
cout<< "Enter Blood group: ";
cin>>blood_grp;
cout<< "Enter Mobile No :";
cin>> mob;
cout<< "Enter Address:";
cin>>addr;
}
// function to display student information
void display()
{
cout<< "\n-----------------------------------------------";
cout<< "\nName :"<<name;
cout<< "\nRoll_no :"<<*rollno;
cout<< "\nYear(SE/TE/BE) :"<<year_class;
cout<< "\nDiv(1/2/3/4/5) :"<<div;
cout<< "\nDoB :"<<DoB;
cout<< "\nBlood group :"<<blood_grp;
cout<< "\nMobile no :"<<mob;
cout<< "\nAddress :"<<addr;
cout<< "\n-----------------------------------------------";
}
//static member function
static void header()
{
cout<<"\n * * * Student Information System * * *";
}
}; // student class ends here
//class faculty
class faculty
{
private:
int id;
public:
faculty()
{
id=000;
}
faculty(const faculty &f1)
{
id = f1.id;
}
voidf_display(student &obj,intf_d)
{
try
{
if (obj.div == f_d)
obj.display();
else
throw ( obj.div);
}
catch (int x)
{
cout<< "\n Invalid Division/ You are not teaching to thid Division.....";
}
}
};
int main(){
studentst[5];
faculty f;
intch=0,count=0;
do
{
cout<< "\n * * * * Student Information System * * * * ";
cout<< "\n * * * Menu * * *";
cout<< "\n 1. Add Information ";
cout<< "\n 2. Display Information";
cout<< "\n 3. Faculty wise Information";
cout<< "\n 4. Exit ";
cout<< "\n Enter choice: ";
cin>>ch;
switch (ch)
{
case 1:
st[count].add_data();
count++;
break;
case 2:
for ( int j = 0; j<count; j++)
{
student::header();
st[j].display();
}
break;
case 3:
intf_div;
cout<< "\n Enter Division of Faculty: ";
cin>>f_div;
for(int j=0; j<count;j++)
{
cout<<"\n* * * Student Information System ( Faculty RAS) * * *";
f.f_display(st[j],f_div);
}
break;
case 4:
exit(0);
}
} while ( ch != 4);
return 0;
}