-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlms.cpp
961 lines (890 loc) · 25.4 KB
/
lms.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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
#include<cmath>
#include<sstream>
#include<stdlib.h>
#include<cstring>
#include<conio.h>
using namespace std;
//****************
//global variables
//****************
int n=0;
int index=0;//used in finding index function
int counter=0;
int flag=0;
int count; // incremented when add course and decremented when delete course
int COUNT; //incremented when student is added and decremented when student is decremented
//*******************
// declaring functions
//*********************
bool IsValidCourseCodeL(string code);//for checking the letters validity of course_code
bool IsValidCourseCodeN(string code);//for checking the numbers validity o fcourse_code
bool IsValidCourseName(string name);//for checking the validation of course_name
bool IsValidCreditHours(int crdHrs);//for checking whether credit hours is between 1-3
bool IsValidSemester(int sem);//for checking whether semester is between 1-8
int CourseIndex(string course_code,string code1[]);//for finding the given course code from the course code list
void AddCourses(string name1[],string code1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem,int i);//Adding courses
void UpdateCourse(string name1[],string char1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem,char course_code[]);//Updating courses
void DeleteCourse(string name1[],string char1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem,char course_code[]);//Deleting courses
void ViewAllCourses(string name1[],string code1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem);//Viewing all the courses
void ViewSemesterCourses(string name1[],string code1[],int crdHrs1[], int sem1[],string name,string code,int crdHrs,int semester);//Viewing the courses semester vice
void saveCourses( string n[], string c[], int crd[],int s[]);//Saving Courses
int str_int(string str);//for changing string to integer
void loadCourses(string name1[],string code1[],int crdHrs1[],int sem1[]);//loading the courses
bool loadUsers(string Userlist[],string Passwordlist[]);//loading the passwords and usenames
bool IsValidStdName(string stdname);//for checking the validation of student name
bool ValidRegNo( char RegNo[] ); //for checking the validation of registration number
void addStudent(string stdNameList[],string stdRegNoList[],string stdname,char Reg_No[]);//Adding students
void updateStudent(string stdNameList[],string stdRegNoList[],string stdName,char RegNo[]);//Updating students
void deleteStudent(string stdNameList[],string stdRegNoList[],string stdName,char RegNo[]);//Deleting Students
int RegIndex(string stdRegNoList[],char RegNo[]);//for finding the given registeration number from the registration number list
void UnRegisterCourses(string stdRegNoList[],string stdCourseList[][50], char course_code[],char RegNo[]);//for Unregistering courses of student
void RegisterCourses(string stdRegNoList[],string stdCourseList[][50], char course_code[],char RegNo[],string code1[]);//for registering courses of student
void view_Std(string RegNoList[],string stdNameList[] ); //Viewing students
bool checkReg(string RegNoList[],char RegNo[]); //checking existence of redistration number inn the regNo list
void saveStudents(string stdRegNoList [],string stdCourseList[][50],string stdNameList[]);//saving student's information
void loadStudents(string stdRegNoList [],string stdCourseList[][50],string stdNameList[]); //loading student's information
//----------------------------------------------
//************************************************
//main function
//*************************************************
//------------------------------------------------
int main()
{
//*********************
//Variables declaration
//*********************
string name1[50]; string code1[50],Userlist[50],Passwordlist[50];
int crdHrs1[50], sem1[50];
char course_code[5];
string stdName;
char RegNo[12];
string stdNameList[50],stdRegNoList[50];
string stdCourseList[50][50]={{"\0"},{"\0"}};
string name, code,Pass; int crdHrs, sem ;
string stdRegNo;
bool condition =true,flag=false;
int op,option;
//************************************************
//choosing whether you are administrator or student
//************************************************
loadCourses(name1 , code1 , crdHrs1 , sem1);
//cout << code1[0] << endl << code1[1] << endl;
loadStudents(stdRegNoList,stdCourseList,stdNameList);
cout<<endl<<" Choose the option for Login :"<<endl;
cout<< " --------------------------------------"<<endl;
cout<<endl<<" 1 for Admin "<<endl;
cout<<endl<<" 2 for student"<<endl<<endl;
cout<<" Enter Option :";
cin>>option;
//****************************************************
//For Admin
//****************************************************
if(option==1)
{
//***********************************
//printing the startup of the program
//***********************************
cout<<" --------------------------------------------------------\n";
cout<<" -------------------------------------------------------\n" ;
cout<<" **Welcome to university learning Management System**\n";
cout<<" -------------------------------------------------------\n";
cout<<" -------------------------------------------------------\n\n";
//*************************************************
//condition will terminate when user enter the op 13
//*************************************************
while(op!=13)
{
if(loadUsers(Userlist,Passwordlist)==true)
{
cout <<endl<< "you have successfully logged in.";
}
else
{
cout<<"Sorry, we are unable to run the program ,as user data doesnot exists "<<endl<<endl;
cout<<" please re-enter username and password :"<<endl<<endl;
main();
}
do
{
//*********************
//Presenting the options
//*********************
cout<<endl<<" Choose the following options\t: "<<endl<<endl<<"-------------------------------"<<endl<<endl<<" 1\tAdd Course"<<endl<<" 2\tUpdate Course"<<endl<<" 3\tDelete Course"<<endl<<" 4\tView All Courses"<<endl<< " 5\tView courses of a semester"<<endl<<" 6\tAdd New Student"<<endl<<" 7\tUpdate Student"<<endl<<" 8\tDelete Student"<<endl<<" 9\tView All Students "<<endl<<" 10\tRegister the Courses for student"<<endl<<" 11\tUnregister the course for student "<<endl<<" 12\t Logout of the system "<<endl<<" 13\tExit Program"<<endl<<endl<<" \tChoose the option\t : "<<endl<<endl;
cin>>op;
//****************
//Switch structure
//***************
switch(op)
{
case 1: //*********Add Courses********
{
int c;
cout<<"Enter the number of courses you want to enter : ";
cin>>c;
for(int i=0;i<c;i++)
{
cout<<endl<<"Enter the course details, code credit hours semester name :";
cin>>code >>crdHrs>>sem ;
getline(cin, name);
AddCourses(name1,code1,crdHrs1,sem1,name,code,crdHrs,sem,i);
}
break;
}
case 2: //**********Update Courses*********
{
cout<<"Enter the course_code you want to edit ";
cin>>course_code;
UpdateCourse( name1, code1, crdHrs1, sem1, name, code, crdHrs, sem, course_code);
break;
}
case 3://**********Delete Courses*********
{
DeleteCourse(name1, code1, crdHrs1, sem1, name, code, crdHrs, sem, course_code);
break;
}
case 4://********View All Courses*********
{
ViewAllCourses(name1,code1,crdHrs1,sem1,name,code,crdHrs,sem);
break;
}
case 5://***********View Semester vise courses*********
{
int semester;
cout<<"Enter the semester whose details you want to see "<<endl;
cin>>semester;
ViewSemesterCourses(name1,code1,crdHrs1,sem1,name,code,crdHrs,semester);
break;
}
case 6://************Add STUDENTS*********
{
cout<<" Enter student name :"<<endl;
cin>>stdName;
cout<<" Enter Registration Number :"<<endl;
cin>>RegNo;
addStudent(stdNameList,stdRegNoList,stdName,RegNo);
for(int i=0;i<count ;i++)
{
cout<<stdNameList[i]<<endl;
cout<<stdRegNoList[i]<<endl;
}
break;
}
case 7://**********Update students*********
{
cout<<"Enter the registration number to edit :"<<endl;
cin>>RegNo;
updateStudent (stdNameList, stdRegNoList, stdName , RegNo);
break;
}
case 8://**************delete students*************
{
cout<<"Enter the registration number to delete :"<<endl;
cin>>RegNo;
deleteStudent( stdNameList, stdRegNoList, stdName,RegNo);
break;
}
case 9://**************view students*********
{
view_Std( stdRegNoList, stdNameList );
break;
}
case 10://***********Register Courses********
{
cout<<endl<<" Enter the registration number of student for course registration "<<endl;
cin>>RegNo;
cout<<" ENter the course_code for registering course"<<endl;
cin>>course_code;
RegisterCourses( stdRegNoList, stdCourseList, course_code, RegNo , code1);
break;
}
case 11://***********Unregister courses*******
{ cout<<endl<<" Enter the registration number of student for course registration "<<endl;
cin>>RegNo;
cout<<" ENter the course_code for un_registering"<<endl;
cin>>course_code;
// UnRegisterCourses( stdRegNoList, stdCourseList, course_code, RegNo, code1);
break;
}
case 12: //********logging out //saving courses and student's information*******
{
cout<<"You have successfully log out.\n\nPlease log in again to get access to the main menu."<<endl;
saveCourses( name1,code1,crdHrs1,sem1);
saveStudents(stdRegNoList,stdCourseList,stdNameList);
break;
}
case 13: //**********Exiting the program******
{
system("CLS");
main();
break;
}
default:
cout<<"Please enter choice from 1-13";
}
}
while(op!=12 && op!=13);
}
}
//**********************************************
//For Student
//**********************************************
else if(option==2)
{
int n;
cout<<endl<<" Enter Registration Number :";
cin>>RegNo;
int r=RegIndex(stdRegNoList,RegNo);
cout << stdNameList[r];
string Pa=stdNameList[r];
int len=Pa.length();
cout<<endl<<" Enter Password :";
cin>>Pass;
int p=0;
int q=0;
for(int i=len-3;i<len;i++)
{
if(Pass[p]==Pa[i])
{
q++;
}
p++;
}
/* if(q==3)
{
flag=true;
}
if(flag==true)*/
{ cout<<" You have succesfully logged in as student "<<endl;
int n1;
do {
cout<<endl<<" Enter 1 to view registered courses ";
cout<<endl<<" Enter 2 to logout of the system ";
cout<<endl<<" Enter 3 to exit "<<endl<<endl;
cout<<" choose option :";
cin>>n1;
switch(n1)
{
case 1:
{
cout<<endl;
cout<<" Enter the registration number to view the registration courses :";
cin>>RegNo;
int s=checkReg(stdRegNoList,RegNo);
cout<<endl<<" Courses :"<<endl<<endl;
for(int i=0;i<5;i++)
{
if(stdCourseList[s][i]!="\0")
{
cout<<stdCourseList[s][i]<<" , ";
}
cout<<endl;
}
break;
}
case 2:
{
main();
}
case 3:
{
return 0;
}
}
}
while(option!=-1);
}
}
/*else
{
cout<<endl<<" Invalid password "<<endl;
main();
}*/
return 0;
}
//***************************
//valid course code(letters)
//***************************
bool IsValidCourseCodeL(string code)
{
bool flag=false;
for(int n=0;n<2;n++)
{
if(code[n]>=';'&& code[n]<=':')
{
flag=true;
}
}
return flag;
}
//***************************
// valid course code(numbers)
//***************************
bool IsValidCourseCodeN(string code)
{
bool flag=false;
for(int n=2;n<5;n++)
{
if(code[n]>='0' && code[n]<='9')
flag=true;
}
return flag;
}
//*********************
// valid Course name
//********************
bool IsValidCourseName(string name)
{
int counter=0, emptyness=0;
bool flag=false;
{
for(int i=0; i<name.size() ; i++)
{
if(isalpha(name[i]) || isspace(name[i])!=0)
{
counter+=1;
if(isspace(name[i])!=0)
{
emptyness++;
}
}
}
}
if(name.size()==counter && emptyness!=counter)
{
flag=true;
}
return flag;
}
//******************
// valid Credit hours
//*******************
bool IsValidCreditHours(int crdHrs)
{
bool flag=false;
if(crdHrs<=3)
{
flag=true;
}
return flag;
}
//*************
//valid semester
//**************
bool IsValidSemester( int sem) // valid semester
{
bool flag=false;
if(sem<=8)
flag=true;
return flag;
}
//***************
//Adding Courses
//***************
void AddCourses(string name1[],string code1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem,int i) // add course
{
bool flag1=IsValidCourseCodeL(code);
bool flagN=IsValidCourseCodeN(code);
if(flag1==true&&flagN==true)
{
bool flag2=IsValidCourseName(name);
if(flag2==true)
{
bool flag3=IsValidCreditHours(crdHrs);
if(flag3==true)
{
bool flag4=IsValidSemester(sem);
if(flag4==true)
{
index = i;
code1[index]= code;
crdHrs1[index]=crdHrs;
sem1[index]=sem;
name1[index]=name;
cout << "\nCourse has been added successfully" << endl;
index++;
flag=0;
count++;
}
else
cout<<"Invalid semester \n";
}
else
cout<<"Invalid credit hours\n";
}
else
cout<<"Invalid coursename \n";
}
else
cout<<" Invalid coursecode \n";
}
//****************************
//For Viewing all the courses
//****************************
void ViewAllCourses(string name1[],string code1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem ) // view all courses
{
cout << left << setw(16) << "CourseCode" << setw(50) << "CourseName" << setw(15) << "CreditHours" << setw(15) << "Semester" << endl;
for(int i=0 ; i<count ;i++)
{
cout<< left << setw(16) << code1[i ]<< setw(50) << name1[i] << setw(15) << crdHrs1[i] << setw(15) << sem1[i] << endl;
}
}
//*******************************
//Viewing Semestervise Courses
//*******************************
void ViewSemesterCourses(string name1[],string code1[],int crdHrs1[],int sem1[],string name,string code ,int crdHrs,int semester) // view semester courses
{
cout<<setw(16)<<"CourseCode"<<setw(50)<<"CourseName"<<setw(15)<<"CreditHours"<<endl;
for(int i=0 ;i<count;i++)
{
if(semester==sem1[i])
{
cout<<setw(16)<<code1[i]<<setw(50)<<name1[i]<<setw(15)<<crdHrs1[i]<<endl;
}
}
}
//*****************************************
//Finding Index of the given Course_code
//**************************************
int CourseIndex(string course_code,string code1[])
{
int newcode;
for(int i=0;i<100;i++)
{
if(code1[i]==course_code)
newcode=i;
break;
}
return newcode;
}
//************
// updation
//************
void UpdateCourse(string name1[],string code1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem,char course_code[])
{
cout<<"Enter the new details of the course :";
cin>>code>>crdHrs>>sem;
getline(cin,name);
if(IsValidSemester(sem) == 1 && IsValidCourseCodeL(code) == 1 && IsValidCreditHours(crdHrs)==1 && IsValidCourseName(name)==1 && IsValidCourseCodeN(code)==1)
{
code1[counter] = code;
name1[counter]=name;
crdHrs1[counter]=crdHrs;
sem1[counter]=sem;
cout<<"Course has been edited succesfully :\n";
}
else
cout<<" Course not found : \n";
}
//**********
// deletion
//**********
void DeleteCourse(string name1[],string code1[],int crdHrs1[],int sem1[],string name,string code,int crdHrs,int sem,char course_code[])
{
int f=-1;
int f_Index;
bool isValid=false;
cout<<"Enter course code: ";
cin>>code;
cin.clear();
for(int i=0 ; i<n ; i++)
{
if(code1[i]==code)
{
isValid=true;
f_Index=i;
}
}
for(int i=f_Index; i<n; i++)
{
code1[i]=code1[i+1];
name1[i]=name[i+1];
crdHrs1[i]=crdHrs1[i+1];
sem1[i]=sem1[i+1];
}
cout<<"Course has been deleted successfully!\n" << n;
count--;
}
//**************
//load courses
//************
void loadCourses(string name1[],string code1[],int crdHrs1[],int sem1[])
{
ifstream input;
input.open("Courses.txt");
string N,Crd,S,C,line;
int c1,s1;
int s=0;
while(getline(input,line))
{
stringstream ss(line);
getline(ss,C,',');
getline(ss,N,',');
getline(ss,Crd,',');
c1=str_int(Crd);
getline(ss,S,',');
s1=str_int(S);
code1[s]=C;
name1[s]=N;
crdHrs1[s]=c1;
sem1[s]=s1;
s++;
}
input.close();
}
//**************
//Save courses
//**************
void saveCourses(string nM[], string c[],int crd[],int s[])
{
ofstream output;
output.open("Courses.txt" ,ios :: app);
for(int i=0;i<n;i++)
{
output<<c[i];
output<<",";
output<<nM[i];
output<<",";
output<<crd[i];
output<<",";
output<<s[i];
output<<"\n";
}
output.close();
}
//******************************
//string to integer conversion
//******************************
int str_int(string str)
{
int n=0;
int size=str.size();
for(int i=0; i<size;i++)
{
n+=(str[--size]-'0')*pow(10,i);
}
return n;
}
//********************************
//Loading Usernames and Passwords
//********************************
bool loadUsers( string Userlist[],string Passwordlist[])
{
int x=0;
string U_N,Pa,U,P,line;
ifstream get;
get.open("Users.txt");
while(getline(get,line))
{
stringstream ss(line);
getline(ss,U,',');
getline(ss,P,'\n');
Userlist[x]=U;
Passwordlist[x]=P;
x++;
}
cout<<"Dear User,current software is intended for authorized users only"<<endl<<" Login to the system to get access"<<endl;
cout<<" Username : ";
cin>>U_N;
cout<<endl<<" Password : ";
cin>>Pa;
get.close();
bool flag;
for(int i=0;i<x;i++)
{
if(Userlist[i] ==U_N&&Passwordlist[i] ==Pa)
{
flag=true;
}
else
flag=false;
}
return flag;
}
//***********************
//Valid Registration No
//**********************
bool ValidRegNo( char RegNo[] )
{
bool flag=false;
int size=12;
for(int i=0;i<size;i++)
{
for(int j=0;j<4;j++)
if(RegNo[j]>='0'&& RegNo[j]<='9')
{
for(int k=6;k<8;k++)
if(RegNo[k]>='A'&& RegNo[k]<='Z')
for(int z=9;z<11;z++)
if(RegNo[z]>='0'&& RegNo[z]<='9')
flag=true;
}
}
return flag;
}
//****************
//Adding students
//***************
void addStudent(string stdNameList[],string stdRegNoList[],string stdname,char RegNo[])
{
static int c=0;
if( IsValidStdName( stdname))
{
if(ValidRegNo( RegNo ))
{
stdNameList[c]=stdname;
stdRegNoList[c]=RegNo;
c++;
COUNT=c;
cout<<" Student has been added succesfully "<<endl<<endl;
}
else
cout<<" Invalid Registeration number "<<endl;
}
else
cout<<" Invalid student name "<<endl;
}
//********************
//valid student name
//*******************
bool IsValidStdName(string stdname) // valid Course name
{
int counter=0, emptyness=0;
bool flag=false;
{
for(int i=0; i<stdname.size() ; i++)
{
if(isalpha(stdname[i]) || isspace(stdname[i])!=0)
{
counter+=1;
if(isspace(stdname[i])!=0)
{
emptyness++;
}
}
}
}
if(stdname.size()==counter && emptyness!=counter)
{
flag=true;
}
return flag;
}
//*****************
//Updating students
//*****************
void updateStudent(string stdNameList[],string stdRegNoList[],string stdName,char RegNo[])
{
int index=RegIndex(stdRegNoList , RegNo);
int c=index;
cout<<"Enter the new details of the students Reg No and student name:"<<endl<<endl;
cin>>RegNo;
getline(cin,stdName);
if( IsValidStdName( stdName))
{
if(ValidRegNo( RegNo ))
{
stdNameList[c]=stdName;
stdRegNoList[c]=RegNo;
}
cout<<"Student has been edited succesfully :\n\n";
}
else
cout<<" student not found : \n\n";
}
//****************************
//finding Registration Number
//****************************
int RegIndex(string stdRegNoList[],char RegNo[])
{
int newRegNo;
for(int i=0;i<100;i++)
{
if(stdRegNoList[i]==RegNo)
newRegNo=i;
break;
}
return newRegNo;
}
//*******************
//Deleting Students
//******************
void deleteStudent(string stdNameList[],string stdRegNoList[],string stdName, char RegNo[])
{
int i=0;
while(stdRegNoList[i]!=" ")
{
int index=RegIndex(stdRegNoList , RegNo);
count++;
for(;i<COUNT;i++)
{
stdRegNoList[index] = stdRegNoList[index+1];
stdNameList[index]=stdNameList[index+1];
cout<<" Student has been deleted succesfully "<<endl<<endl;
}
stdRegNoList[COUNT] = " " ;
stdNameList [COUNT] = " " ;
COUNT--;
}
}
//*******************************************
//Checking existence of registeration number
//*****************************************
bool checkReg(string RegNoList[],char RegNo[])
{
bool flag=false;
for(int i=0;i<50;i++ )
{
if(RegNoList[i]==RegNo)
flag=true;
}
return flag;
}
//*********************
//Registering Courses
//********************
void RegisterCourses(string stdRegNoList[],string stdCourseList[][50], char course_code[],char RegNo[], string code1[])
{
int index=RegIndex(stdRegNoList , RegNo);
if(checkReg( stdRegNoList , RegNo))
{
if(ValidRegNo( RegNo ))
{
if(IsValidCourseCodeL(course_code)&&IsValidCourseCodeN(course_code))
{
for(int i=0;i<50;i++)
{
if(stdCourseList[index][i]=="\0")
{
stdCourseList[index][i]= course_code;
cout << endl << "Course has been registered successfully...."<< endl ;
//cout << stdCourseList[index][i] << endl;
}
}
}
else
{
cout<<"Invalid Course code"<<endl;
}
}
else
{
cout<<"Invalid RegNo"<<endl;
}
}
else
{
cout<<"course not found "<<endl;
}
}
//**************************
//Unregistering the courses
//*************************
void UnRegisterCourses(string stdRegNoList[],string stdCourseList[][50], char course_code[],char RegNo[],string code1[])
{ int Nreg=0;
if(checkReg( stdRegNoList , RegNo))
{
if(ValidRegNo( RegNo ))
{
if(IsValidCourseCodeL(course_code)&&IsValidCourseCodeN(course_code))
{
int index=RegIndex(stdRegNoList , RegNo);
int Nreg=0;
for(int i=0;i<50;i++)
{
if(stdCourseList[index][i]==course_code)
{
Nreg=i;
break;
}
}
}
else
{
cout<<"Invalid Course code"<<endl;
}
}
else
{
cout<<"Invalid RegNo"<<endl;
}
}
else
{
cout<<"course not found "<<endl;
}
while(stdCourseList[index][Nreg+1]!="\0")
{
stdCourseList[index][Nreg]=stdCourseList[index][Nreg];
Nreg++;
}
}
//****************
//viewing students
//****************
void view_Std(string RegNoList[],string stdNameList[] )
{
cout << right << setw(25)<< "Name" << right << setw(20) << "Reg. No. "<< endl;
for(int i=0;i<COUNT; i++)
{
cout << right << setw(25) << stdNameList[i] << right << setw(25) << RegNoList[i] << endl;
}
}
//*******************************
// Saving Student's information
//********************************
void saveStudents(string stdRegNoList [],string stdCourseList[][50],string stdNameList[])
{
ofstream output("Student.txt",ios::app);
for(int i=0;i<COUNT;i++)
{
output<<stdRegNoList[i];
output<<",";
output<< stdNameList[i];
output<<endl;
for(int j=0; j<COUNT; j++)
{
if(stdCourseList[i][j]!="\0")
{
output << stdCourseList[i][j]<<",";
}
}
output<<endl;
}
output.close();
}
//*******************************
//loading student's information
//*******************************
void loadStudents(string stdRegNoList [],string stdCourseList[][50],string stdNameList[])
{
ifstream outFile("Student.txt");
string line1 , line2 ;
string N;
string R;
string C;
int n=0 ; int i=0;
while(getline(outFile , line1))
{
stringstream ss (line1);
getline( ss , R , ',');
getline( ss , N ,',' );
stdNameList[n]=N;
stdRegNoList[n]= R;
//cout << endl << stdNameList[n] << " ," << stdRegNoList[n] ;
getline(outFile , line2);
stringstream ss2(line2);
for(int k=0; k<5 ; k++)
{
getline(ss2 , C ,',');
stdCourseList[n][i]=C;
// cout << endl << stdCourseList[n][i] << " ";
i++;
}
n++;
}
outFile.close();
}