Hostel management systems are software solutions used within hostels, in order to carry out key managerial tasks and oversee operations.
In this c++ code, you can learn about what these systems are, how they work, why they are so useful, what their main features are, and how much they cost.
C++ Code:
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 364 365 366 367 368 369 370 371 372 373 374 375 376 | #include<iostream.h> #include<conio.h> #include<string.h> #include<fstream> #include<cstring> using namespace std; int adminView(); int studentView(); int studentLogin(); int checkCredentials(string userName, string password); int getAllStudentsbyRollNo(); int deleteAllStudents(); int deleteStudentbyRollno(); int checkListOfStudentsRegistered(); int checkPresenseCountbyRollno(); int getListOfStudentsWithTheirPresenseCount(); int registerStudent(); int adminLogin(); int registerStudent(); int markMyAttendance(string username); int countMyAttendance(string username); int delay(); int delay() { for(int i = 0; i<3; i ++) { cout<<"\n Saving Records ..."; for(int ii = 0; ii<20000; ii ++) { for(int iii = 0; iii<20000; iii ++) { } } } cout<<"\n Exiting Now ..."; for(int i = 0; i<3; i ++){ for(int ii = 0; ii<20000; ii ++) { for(int iii = 0; iii<20000; iii ++){ } } } return 0; } int adminView() { int goBack = 0; while(1) { system("cls"); cout<<"\n 1 Register a Student"; cout<<"\n 2 Delete All students name registered"; cout<<"\n 3 Delete student by rollno"; cout<<"\n 4 Check List of Student registered by userame"; cout<<"\n 5 Check presense count of any student by Roll No"; cout<<"\n 6 Get List of student with their attendance count"; cout<<"\n 0. Go Back <- \n"; int choice; cout<<"\n Enter you choice: "; cin>>choice; switch(choice) { case 1: registerStudent();break; case 2: deleteAllStudents(); break; case 3: deleteStudentbyRollno(); break; case 4: checkListOfStudentsRegistered(); break; case 5: checkPresenseCountbyRollno(); break; case 6: getListOfStudentsWithTheirPresenseCount(); break; case 0: goBack = 1;break; default: cout<<"\n Invalid choice. Enter again "; getchar(); } if(goBack == 1) { break; } } return 0; } int studentLogin() { system("cls"); cout<<"\n -------- Student Login ---------"; studentView(); delay(); return 0; } int adminLogin() { system("cls"); cout<<"\n --------- Admin Login --------"; string username; string password; cout<<"\n Enter username : "; cin>>username; cout<<"\n Enter password : "; cin>>password; if(username=="admin" && password=="admin@2") { adminView(); getchar(); delay(); } else { cout<<"\n Error ! Invalid Credintials.."; cout<<"\n Press any key for main menu "; getchar();getchar(); } return 0; } int checkStudentCredentials(string username, string password) { ifstream read; read.open("db.dat"); if (read) { int recordFound = 0; string line; string temp = username + password + ".dat"; cout<<"\n file name is : "<<temp; while(getline(read, line)) { if(line == temp) { recordFound = 1; break; } } if(recordFound == 0) return 0; else return 1; } else { return 0; } } int getAllStudentsbyName() { cout<<"\n List of All Students by their Name \n"; cout<<"\n Please any key to continue.."; getchar();getchar(); return 0; } int getAllStudentsbyRollNo() { cout<<"\n List of All Students by their Roll No \n"; cout<<"\n Please any key to continue.."; getchar();getchar(); return 0; } int deleteStudentbyRollno() { cout<<"\n Delete any Student by their Roll No \n"; cout<<"\n Please any key to continue.."; getchar();getchar(); return 0; } int checkPresenseCountbyRollno() { cout<<"\n Check presense count of any Student by Roll No \n"; cout<<"\n Please any key to continue.." ; getchar();getchar(); return 0; } int checkAllPresenseCountbyRollno() { cout<<"\n Check presense count of All Students by Roll No & Name \n"; cout<<"\n Please any key to continue.." ; getchar();getchar(); return 0; } int studentView() { cout<<"\n ------- Student Login-------- \n"; string username, password; cout<<"\n Enter username : "; cin>>username; cout<<"\n Enter password : "; cin>>password; int res = checkStudentCredentials(username, password); if(res == 0) { cout<<"\n Invalid Credentials !!"; cout<<"\n Press any key for Main Menu.."; getchar(); getchar(); return 0; } int goBack = 0; while(1) { system("cls"); cout<<"\n 1 Mark Attendance fo Today "; cout<<"\n 2 Count my Attendance"; cout<<"\n 0. Go Back <- \n"; int choice; cout<<"\n Enter you choice: "; cin>>choice; switch(choice) { case 1: markMyAttendance(username); break; case 2: countMyAttendance(username); break; case 0: goBack = 1;break; default: cout<<"\n Invalid choice. Enter again "; getchar(); } if(goBack == 1) { break; } } } int markMyAttendance(string username) { cout<<"\n Mark Attendance for today !!"; cout<<"\n Please any key to continue.."; getchar();getchar(); return 0; } int countMyAttendance(string username) { cout<<"\n Count my attendace for today !!"; cout<<"\n Please any key to continue.."; getchar();getchar(); return 0; } int deleteAllStudents() { cout<<"\n In delete all students !!"; cout<<"\n Please any key to continue.."; getchar(); getchar(); return 0; } int checkListOfStudentRegistered() { cout<<"\n List of All registered registered !!"; cout<<"\n Please any key to continue.."; getchar(); getchar(); return 0; } int getListOfStudentsWithTheirPresenseCount() { cout<<"\n All Students with their Presense count !!"; cout<<"\n Please any key to continue.."; getchar(); getchar(); return 0; } int checkListOfStudentsRegistered(){ cout<<"\n - Check List of Student Registered by Username-- "; ifstream read; read.open("db.dat"); if(read) { int recordFound =0; string line; while(getline(read, line)) { char name[100]; strcpy(name, line.c_str()); char onlyname[100]; strncpy(onlyname, name, (strlen(name) - 4)); cout<<" \n " << onlyname; } read.close(); } else { cout<<"\n No Record found :("; } cout<<"\n Please any key to continue.."; getchar(); getchar(); return 0; } int registerStudent() { cout<<"\n ----- Form to Register Student ---- \n"; string name, username, password, rollno, address, father, mother; cout<<"\n Enter Name : "; cin>>name; cout<<"\n Enter Username : "; cin>>username; cout<<"\n Enter password : "; cin>>password; cout<<"\n Enter rollno : "; cin>>rollno; getchar(); char add[100]; cout<<"\n Enter address : "; cin.getline(add, 100); cout<<"\n Enter father : "; cin>>father; cout<<"\n Enter mother : "; cin>>mother; ifstream read; read.open("db.dat"); if(read) { int recordFound =0; string line; while(getline(read, line)) { if(line == username+".dat" ) { recordFound = 1 ; break; } } if(recordFound == 1) { cout<<"\n Username already Register. Please choose another username "; getchar(); getchar(); delay(); read.close(); return 0; } } read.close(); ofstream out; out.open("db.dat", ios::app); out<<username+".dat"<<"\n"; out.close(); ofstream out1; string temp = username+".dat"; out1.open(temp.c_str()); out1<<name<<"\n"; out1<<username<<"\n"; out1<<password<<"\n"; out1<<rollno<<"\n"; out1<<add<<"\n"; out1<<father<<"\n"; out1<<mother<<"\n"; out1.close(); cout<<"\n Student Registered Successfully !!"; cout<<"\n Please any key to continue.."; getchar(); getchar(); return 0; } int main(int argc, char** argv) { while(1) { system("cls"); cout<<"\n Webeduclick Hostel Management System \n"; cout<<"*************************************\n\n"; cout<<"1. Hostel Student Login\n"; cout<<"2. Hostel Administrator Login\n"; cout<<"0. Exit\n"; int choice; cout<<"\n Enter you choice: "; cin>>choice; switch(choice) { case 1: studentLogin(); break; case 2: adminLogin(); break; case 0: while(1) { system("cls"); cout<<"\n Are you sure, you want to exit? y | n \n"; char ex; cin>>ex; if(ex == 'y' || ex == 'Y') exit(0); else if(ex == 'n' || ex == 'N') { break; } else{ cout<<"\n Invalid choice !!!"; getchar(); } } break; default: cout<<"\n Invalid choice. Enter again "; getchar(); } } return 0; |
Output: