-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchoolManagementSystem.cpp
More file actions
363 lines (356 loc) · 11.8 KB
/
SchoolManagementSystem.cpp
File metadata and controls
363 lines (356 loc) · 11.8 KB
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
// Student Management system using file handling in c++
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cstdlib>
#include <conio.h>
#include <string>
#include <string_view>
#include <regex>
#include <stdio.h>
using namespace std;
class student
{
private:
string name, roll_no, course, address, email_id, contact_no;
public:
void menu();
void insert();
void display();
void modify();
void search();
void deleted();
};
void student::menu()
{
menustart:
int choice;
char x;
system("cls");
cout << "\t\t\t-----------------------------" << endl;
cout << "\t\t\t| STUDENT MANAGEMENT SYSTEM |" << endl;
cout << "\t\t\t-----------------------------" << endl;
cout << "\t\t\t 1. Enter New Record" << endl;
cout << "\t\t\t 2. Display Record" << endl;
cout << "\t\t\t 3. Modify Record" << endl;
cout << "\t\t\t 4. Search Record" << endl;
cout << "\t\t\t 5. Delete Record" << endl;
cout << "\t\t\t 6. Exit" << endl;
cout << "\t\t\t-----------------------------" << endl;
cout << "\t\t\t Choose Option:[1/2/3/4/5/6]" << endl;
cout << "\t\t\t-----------------------------" << endl;
cout << "Enter Your Choose: ";
cin >> choice;
switch (choice)
{
case 1:
do
{
insert();
cout << "\n Add Another Student Record (Y,N): ";
cin >> x;
} while (x == 'y' || x == 'Y');
break;
case 2:
display();
break;
case 3:
modify();
break;
case 4:
search();
break;
case 5:
deleted();
break;
case 6:
exit(0);
default:
cout << "\n Invalid choice... Please Try Again..";
}
getch();
goto menustart;
}
void student::insert() // add student details
{
system("cls");
fstream file;
cout << "\n-----------------------------------------------------------------------------------------------------";
cout << "\n------------------------------------- Add Student Details ---------------------------------------------" << endl;
cout << "\t\t\tEnter Name: ";
cin >> name;
cout << "\t\t\tEnter Roll No.: ";
cin >> roll_no;
cout << "\t\t\tEnter Course: ";
cin >> course;
cout << "\t\t\tEnter Email Id: ";
cin >> email_id;
cout << "\t\t\tEnter Contact No: ";
cin >> contact_no;
cout << "\t\t\tEnter Address: ";
cin >> address;
file.open("studentRecord.txt", ios::app | ios::out);
file << " " << name << " " << roll_no << " " << course << " " << email_id << " " << contact_no << " " << address << "\n";
file.close();
}
void student::display() // display students details
{
system("cls");
fstream file;
int total = 1;
int temp = 0;
cout << "\n-------------------------------------------------------------------------------------------------------" << endl;
cout << "------------------------------------- Student Record Table --------------------------------------------" << endl;
file.open("studentRecord.txt", ios::in);
if (!file)
{
/* code */
cout << "\n No Data Is Present...";
file.close();
}
else
{
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
while (!file.eof())
{
cout << "\n\n\t\t\t Student No.: " << total++ << endl;
cout << "\t\t\t Student Name: " << name << endl;
cout << "\t\t\t Student Roll No.: " << roll_no << endl;
cout << "\t\t\t Student course: " << course << endl;
cout << "\t\t\t Student Email Id.: " << email_id << endl;
cout << "\t\t\t Student Contact No.: " << contact_no << endl;
cout << "\t\t\t Student Address: " << address << endl;
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
temp++;
}
if (temp == 0)
{
cout << "\nNo Data Is Present...";
}
}
file.close();
}
void student::modify() // Modify Students Details
{
system("cls");
fstream file, file1;
string rollno;
int found = 0;
cout << "\n-------------------------------------------------------------------------------------------------------" << endl;
cout << "------------------------------------- Student Modify Details ------------------------------------------" << endl;
file.open("studentRecord.txt", ios::in);
if (!file)
{
cout << "\n No Data is Present..";
}
else
{
cout << "\n\t\t\tEnter Roll No. of Student which you want to Modify: ";
cin >> rollno;
file1.open("record.txt", ios::app | ios::out);
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
if (file.eof())
{
cout << "\n No Data is Present..";
}
while (!file.eof())
{
if (rollno != roll_no)
{
file1 << " " << name << " " << roll_no << " " << course << " " << email_id << " " << contact_no << " " << address << "\n";
}
else
{
char ch;
cout << "\n\t\t\tDo you want to modify the name of the student? (Y/N) ";
cin >> ch;
if (ch == 'Y' || ch == 'y')
{
cout << "\t\t\tEnter Name: ";
cin >> name;
cout << "\t\t\tNew Name: ";
cout << name;
}
else
{
cout << "\t\t\tName: ";
cout << name;
}
cout << "\n\t\t\tDo you want to modify the Roll No. of the student? (Y/N) ";
cin >> ch;
if (ch == 'Y' || ch == 'y')
{
cout << "\t\t\tEnter Roll No.: ";
cin >> roll_no;
cout << "\t\t\tNew Roll No.: ";
cout << roll_no;
}
else
{
cout << "\t\t\tRoll No.: ";
cout << roll_no;
}
cout << "\n\t\t\tDo you want to modify the Course of the student? (Y/N) ";
cin >> ch;
if (ch == 'Y' || ch == 'y')
{
cout << "\t\t\tEnter Course: ";
cin >> course;
cout << "\t\t\tNew Course: ";
cout << course;
}
else
{
cout << "\t\t\tCourse: ";
cout << course;
}
cout << "\n\t\t\tDo you want to modify the Email Id of the student? (Y/N) ";
cin >> ch;
if (ch == 'Y' || ch == 'y')
{
cout << "\t\t\tEnter Email Id: ";
cin >> email_id;
cout << "\t\t\tNew Email Id: ";
cout << email_id;
}
else
{
cout << "\t\t\tEmail Id: ";
cout << email_id;
}
cout << "\n\t\t\tDo you want to modify the Contact No. of the student? (Y/N) ";
cin >> ch;
if (ch == 'Y' || ch == 'y')
{
cout << "\t\t\tEnter Contact No.: ";
cin >> contact_no;
cout << "\t\t\tNew Contact No.: ";
cout << contact_no;
}
else
{
cout << "\t\t\tContact No.: ";
cout << contact_no;
}
cout << "\n\t\t\tDo you want to modify the Address of the student? (Y/N) ";
cin >> ch;
if (ch == 'Y' || ch == 'y')
{
cout << "\t\t\tEnter Address: ";
cin >> address;
cout << "\t\t\tNew Address: ";
cout << address;
}
else
{
cout << "\t\t\tAddress: ";
cout << address;
}
file1 << " " << name << " " << roll_no << " " << course << " " << email_id << " " << contact_no << " " << address << "\n";
found++;
}
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
}
if (found == 0)
{
cout << "\n\n Student Roll No. Not Found....";
}
file1.close();
file.close();
remove("studentRecord.txt");
rename("record.txt", "studentRecord.txt");
}
}
void student::search() // search data of student
{
system("cls");
fstream file;
int found = 0;
file.open("studentRecord.txt", ios::in);
if (!file)
{
cout << "\n-------------------------------------------------------------------------------------------------------" << endl;
cout << "------------------------------------- Student Search Data ------------------------------------------" << endl;
cout << "\n No Data Is Present...";
}
else
{
string rollno;
cout << "\n-------------------------------------------------------------------------------------------------------" << endl;
cout << "------------------------------------- Student Search Data ------------------------------------------" << endl;
cout << "\n Enter Roll No. of Student Which You Want to Search: ";
cin >> rollno;
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
while (!file.eof())
{
if (rollno == roll_no)
{
cout << "\n\t\t\t Student Name: " << name << endl;
cout << "\t\t\t Student Roll No.: " << roll_no << endl;
cout << "\t\t\t Student course: " << course << endl;
cout << "\t\t\t Student Email Id.: " << email_id << endl;
cout << "\t\t\t Student Address: " << address << endl;
found++;
}
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
}
if (found == 0)
{
cout << "\n\n Student Roll No. Not Found...";
}
file.close();
}
}
void student::deleted()
{
system("cls");
fstream file, file1;
int found = 0;
string roll;
cout << "\n-------------------------------------------------------------------------------------------------------" << endl;
cout << "------------------------------------- Delete Student Details ------------------------------------------" << endl;
file.open("studentRecord.txt", ios::in);
if (!file)
{
cout << "\nNo Data is Present..";
file.close();
}
else if (file.eof())
{
cout << "\n No Data is Present..";
}
else
{
cout << "\nEnter Roll No. of Student which you want Delete Data: ";
cin >> roll;
file1.open("record.txt", ios::app | ios::out);
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
while (!file.eof())
{
if (roll != roll_no)
{
file1 << " " << name << " " << roll_no << " " << course << " " << email_id << " " << contact_no << " " << address << "\n";
}
else
{
found++;
cout << "\n Successfully Delete Data";
}
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
}
if (found == 0)
{
cout << "\n\n Student Roll NO. Not Found....";
}
file1.close();
file.close();
remove("studentRecord.txt");
rename("record.txt", "studentRecord.txt");
}
}
int main()
{
student project;
project.menu();
return 0;
}