-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentManagementSystem.cpp
More file actions
277 lines (270 loc) · 8.98 KB
/
StudentManagementSystem.cpp
File metadata and controls
277 lines (270 loc) · 8.98 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
#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\tChoose 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\t\t\t 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\t\t\t 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;
cout << "\n-------------------------------------------------------------------------------------------------------" << endl;
cout << "------------------------------------- Student Record Table --------------------------------------------" << endl;
file.open("studentRecord.txt", ios::in);
if (!file)
{
/* code */
cout << "\n\t\t\tNo 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;
}
if (total == 0)
{
cout << "\n\t\t\tNo 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\t\t\tNo Data is Present..";
}
else
{
cout << "\nEnter 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;
while (!file.eof())
{
if (rollno != roll_no)
file1 << " " << name << " " << roll_no << " " << course << " " << email_id << " " << contact_no << " " << address << "\n";
else
{
cout << "\n\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;
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\t\t\t 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\t\t\t 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\t\t\tStudent 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 << "\n\t\t\tNo Data is Present..";
file.close();
}
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\t\t\tSuccessfully Delete Data";
}
file >> name >> roll_no >> course >> email_id >> contact_no >> address;
}
if (found == 0)
{
cout << "\n\t\t\t Student Roll NO. Not Found....";
}
file1.close();
file.close();
remove("studentRecord.txt");
rename("record.txt", "studentRecord.txt");
}
}
main()
{
student project;
project.menu();
return 0;
}