-
Notifications
You must be signed in to change notification settings - Fork 0
/
OOP_Prac02.cpp
139 lines (136 loc) · 3.02 KB
/
OOP_Prac02.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
#include <iostream>
#include <string>
using namespace std;
class student
{
private:
string name, DOB, blood_grp, addr, year_class, mob;
int *roll_no;
char div;
public:
friend class faculty;
student()
{
roll_no = new int;
*roll_no = -1;
div = -1;
name = blood_grp = DOB = addr = year_class = mob = " ";
}
~student()
{
delete roll_no;
}
void getdata()
{
cout << "\n\t Enter Student Information ";
cout << "\nEnter your name: ";
cin.ignore();
getline(cin, name);
cout << "\nEnter Roll_no: ";
cin >> *roll_no;
cout << "\nEnter year(SE/TE/BE): ";
cin >> year_class;
cout << "\nEnter Division (A/B): ";
cin >> div;
cout << "\nEnter DOB: ";
cin >> DOB;
cout << "\nEnter Blood group: ";
cin >> blood_grp;
cout << "\nEnter mobile no: ";
cin >> mob;
cout << "\nEnter your address: ";
cin >> addr;
}
void display()
{
cout << "\n\nName :" << name;
cout << "\nRoll No :" << roll_no;
cout << "\nYear(SE/TE/BE) :" << year_class;
cout << "\nDiv (A/B) :" << div;
cout << "\nDate Of Birth :" << DOB;
cout << "\nBlood Group :" << blood_grp;
cout << "\nMobile No :" << mob;
cout << "\nAddress :" << addr;
cout << endl;
}
static void header()
{
cout << "\nSTUDENT DATABASE ";
}
};
class faculty
{
private:
int id;
public:
faculty()
{
id = 000;
}
faculty(const faculty &f1)
{
id = f1.id;
}
void f_display(student &obj, int f_d)
{
try
{
if (obj.div == f_d)
{
obj.display();
}
else
{
throw(obj.div);
}
}
catch (int x)
{
cout << "\nInvalid Division";
}
}
};
int main()
{
student s[5];
faculty f;
int ch = 0, count = 0;
while (ch != 4)
{
cout << "\n***** MENU *****";
cout << "\n1.Add Student";
cout << "\n2.Display Student Information";
cout << "\n3.Faculty wise Information";
cout << "\n4.Exit\n";
cout << "\nEnter your choice: ";
cin >> ch;
switch (ch)
{
case 1:
s[count].getdata();
count++;
break;
case 2:
for (int i = 0; i < count; i++)
{
student::header();
s[i].display();
}
break;
case 3:
char f_div;
cout << "\nEnter division of faculty: ";
cin >> f_div;
for (int i = 0; i < count; i++)
{
cout << "\nSTUDENT INFORMATION SYSTEM\n";
f.f_display(s[i], f_div);
}
break;
case 4:
cout << "\n***** SUCCESSFULLY TERMINATED *****\n";
break;
}
}
return 0;
}