-
Notifications
You must be signed in to change notification settings - Fork 2
/
5.student.cpp
210 lines (192 loc) · 4.29 KB
/
5.student.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//OOP PROGRAM NO.5 STUDENT DATABASE DELETION INCOMPLETE
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
class student
{
private:
int rno;
char nm[20];
char clas[20];
char division;
char dob[20];
char bg[20];
char tno[20];
char drivinglicno[20];
char email[20];
bool status;
public:
student()
{
rno=00;
division=00;
strcpy(nm,"");
strcpy(clas,"");
strcpy(dob,"");
strcpy(bg,"");
strcpy(tno,"");
strcpy(drivinglicno,"");
strcpy(email,"");
}
friend class db;
};
class db
{
private:
student s[10];
int j=0; //imp set intially j=0
public:
//-------------------------------------------------------------------
db()
{
}
//-------------------------------------------------------------------
void adddata()
{
cout<<"\nenter roll no : ";
cin>>s[j].rno; //s[0].rollno
cout<<"\nenter name : ";
cin>>s[j].nm;
cout<<"\nenter class : ";
cin>>s[j].clas;
cout<<"\nenter division : ";
cin>>s[j].division;
cout<<"\nenter date of birth : ";
cin>>s[j].dob;
cout<<"\nenter blood group : ";
cin>>s[j].bg;
cout<<"\nenter telephone no. : ";
cin>>s[j].tno;
cout<<"\nenter driving license no. : ";
cin>>s[j].drivinglicno;
cout<<"\nenter email : ";
cin>>s[j].email;
s[j].status=true; //default print status true so it will print all
j++; //imp
}
//-------------------------------------------------------------------
void display()
{
int i;
for(i=0;i<j;i++)
{
if(s[i].status==true) //STATUS==FALSE;
{
cout<<"\nroll no is : "<<s[i].rno;
cout<<"\nname is : "<<s[i].nm;
cout<<"\nenter class : "<<s[i].clas;
cout<<"\nenter division : "<<s[i].division;
cout<<"\nenter date of birth : "<<s[i].dob;
cout<<"\nenter blood group : "<<s[i].bg;
cout<<"\nenter telephone no. : "<<s[i].tno;
cout<<"\nenter driving license no. : "<<s[i].drivinglicno;
cout<<"\nenter email : "<<s[i].email;
cout<<"\n--------------------------------------";
}
}
}
//-------------------------------------------------------------------
void search()
{
int x,i;
cout<<"\nenter the roll no to search - ";
cin>>x;
for(i=0;i<j;i++)
{
if(x==s[i].rno)
{
cout<<"\nroll no is - "<<s[i].rno;
cout<<"\nname is - "<<s[i].nm;
cout<<"\nenter class : "<<s[i].clas;
cout<<"\nenter division : "<<s[i].division;
cout<<"\nenter date of birth : "<<s[i].dob;
cout<<"\nenter blood group : "<<s[i].bg;
cout<<"\nenter telephone no. : "<<s[i].tno;
cout<<"\nenter driving license no. : "<<s[i].drivinglicno;
cout<<"\nenter email : "<<s[i].email;
cout<<"\n--------------";
return ;// if not return it will print "NUMBER NOT FOUND"
}
}
cout<<x<<" no. not found";
}
//-------------------------------------------------------------------
void delete1()
{
int x,i;
cout<<"\nenter the roll no to delete - ";
cin>>x;
for(i=0;i<j;i++)
{
if(x==s[i].rno)
{
s[i].status=false;
return;
}
}
cout<<x<<" no. not found";
}
//-------------------------------------------------------------------
void modify()
{
int x,i;
cout<<"\nenter the roll no to modify - ";
cin>>x;
for(i=0;i<j;i++)
{
if(x==s[i].rno)
{
cout<<"\nenter class : ";
cin>>s[i].clas;
cout<<"\nenter division : ";
cin>>s[i].division;
cout<<"\nenter telephone no. : ";
cin>>s[i].tno;
cout<<"\nenter email : ";
cin>>s[i].email;
cout<<"\n--------------";
return;
}
}
cout<<x<<" no. not found";
}
//-------------------------------------------------------------------
};
main()
{
db d1;
int op=-1;
while(op!=0)
{
cout<<"\n1.Add Data";
cout<<"\n2.Displsy Data";
cout<<"\n3.Search";
cout<<"\n4.Delete";
cout<<"\n5.Modify";
cout<<"\n6.Exit";
cout<<"\n\nEnter Choice : ";
cin>>op;
switch(op)
{
case 1:
d1.adddata();
break;
case 2:
d1.display();
break;
case 3:
d1.search();
break;
case 4:
d1.delete1();
break;
case 5:
d1.modify();
break;
case 6:
op=0;
break;
}
}
}