School Management Project C++
School Management Project C++
School Management Project C++
student file
char studentName[30];
int rollNo;
char fatherName[30];
char motherName[30];
char address[80];
char bloodGroup[4];
public:
cout<<"Address : "<<address<<endl;
return rollNo;
char * retString(char x){ //Return all strings avaialable from the Student Class
if(x=='T')
return strTitle(title);
if(x=='N')
return studentName;
if(x=='F')
return fatherName;
if(x=='M')
return motherName;
if(x=='A')
return address;
if(x=='B')
return bloodGroup;
return retString('N');
};
system("CLS");
do{
title = scan();
do{
gets(studentName);
}while(strlen(studentName)==0);
do{
rollNo=scan();
}while(rollNo<1);
do{
gets(fatherName);
}while(strlen(fatherName)==0);
do{
gets(motherName);
}while(strlen(motherName)==0);
do{
gets(address);
}while(strlen(address)==0);
int v = 0,i;
do{
gets(bloodGroup);
for(i=0;i<8;i++)
if(!strcmp(bloodGroup,bGs[i])){
v=1;
break;
}while(!v);
system("CLS");
do{
title=scan();
else if(ch=='N'){
do{
gets(studentName);
}while(strlen(studentName)==0);
else if(ch=='R'){
fstream fl(FLBSTUD,ios::in|ios::binary);
Student obj;
do{
rollNo = scan();
fl.close();
fl.open(FLBSTUD,ios::in|ios::binary);
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
rollNo = -1;
}while(rollNo<1);
fl.close();
else if(ch=='F'){
do{
gets(fatherName);
}while(strlen(fatherName)==0);
}
else if(ch=='M'){
do{
gets(motherName);
}while(strlen(motherName)==0);
else if(ch=='A'){
do{
gets(address);
}while(strlen(address)==0);
else {
int v = 0,i;
do{
for(i=0;i<8;i++)
if(!strcmp(bloodGroup,bGs[i])){
v=1;
break;
}while(!v);
int class_standard;
char studentName[30];
int rollNo;
char Subject[30];
public:
if(i)
cout<<"Subject : "<<Subject<<endl;
return class_standard;
return rollNo;
char * retString(char x){ //Return all strings avaialable from the Class class
if(x=='N')
return studentName;
if(x=='S')
return Subject;
return retString('N');
};
system("CLS");
do{
class_standard = scan();
}while(class_standard>12 || class_standard<1);
do{
gets(studentName);
}while(strlen(studentName)==0);
do{
rollNo = scan();
}while(rollNo<1);
do{
gets(Subject);
}while(strlen(Subject)==0);
system("CLS");
if(ch=='C'){
do{
class_standard = scan();
}while(class_standard>12 || class_standard<1);
else if(ch=='N'){
do{
gets(studentName);
}while(strlen(studentName)==0);
else if(ch=='R'){
fstream fl(FLBCLAS,ios::in|ios::binary);
Class obj;
do{
rollNo = scan();
fl.close();
fl.open(FLBCLAS,ios::in|ios::binary);
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
rollNo=-1;
}while(rollNo<1);
fl.close();
else {
cout<<"Subject : ";
int v = 0,i;
do{
gets(Subject);
}while(strlen(Subject)==0);
system("CLS");
Student obj,obj2;
char ch;
int v=0;
obj.getDetails();
ofstream fl2;
fl2.open(FLBSTUD,ios::out|ios::binary);
fl2.write((char*)&obj, sizeof(obj));
fl2.close();
return;
while(!fl1.eof()){
fl1.read((char*)&obj2,sizeof(obj));
if(fl1.eof()){
break;
cout<<"Record with same Roll No. with following details already exists :
\n";
obj2.printDetails();
return;
else if(strcmpi(obj.retStudentName(),obj2.retStudentName())==0){
obj2.printDetails();
cout<<'\n';
v=1;
if(v){
cin>>ch;
ch = toupper(ch);
if(ch=='N'){
return;
fl2.open(FLBSTUD,ios::out|ios::app|ios::binary);
fl2.seekp(0,ios::end);
fl2.write((char*)&obj, sizeof(obj));
fl2.close();
system("CLS");
Class obj,obj2;
char ch;
int v=0;
obj.getDetails();
ofstream fl2;
fl2.write((char*)&obj, sizeof(obj));
fl2.close();
return;
while(!fl1.eof()){
fl1.read((char*)&obj2,sizeof(obj));
if(fl1.eof()){
break;
cout<<"Record with same Roll No. with following details already exists :
\n";
obj2.printDetails();
return;
else if(strcmpi(obj.retStudentName(),obj2.retStudentName())==0){
if (!v)
//Warns user if record with same Roll No. Already Exists
obj2.printDetails();
cout<<'\n';
v=1;
do{
cin>>ch;
ch = toupper(ch);
if(ch=='N'){
return;
fl2.open(FLBCLAS,ios::out|ios::app|ios::binary);
fl2.seekp(0,ios::end);
fl2.write((char*)&obj, sizeof(obj));
fl2.close();
Class obj;
int v=0;
return 0;
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
v=1;
obj.printDetails();
RULE('-');
fl.close();
if(!v)
return v;
system("CLS");
Student obj;
int v=0;
return 0;
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
v=1;
obj.printDetails();
RULE('-');
fl.close();
if(!v)
return v;
fstream fl(FLBCLAS,ios::in|ios::ate|ios::binary);
return 0;
}
fl.close();
fl.open(FLBCLAS,ios::in|ios::binary);
int cl;
char ch;
char query[30];
Class obj;
int found = 0;
do{
cin>>cl;
}while(cl>12 || cl<0);
cout<<" (S)ubject.\n";
do{
cin>>ch;
ch = toupper(ch);
do{
gets(query);
}while(strlen(query)==0);
while(!fl.eof()){
fl.read((char*)&obj,sizeof(obj));
if(fl.eof()){
break;
}
if((strcmpi(query,obj.retString(ch))==0)){
if(!found)
obj.printDetails();
RULE('-');
found = 1;
if(!found)
fl.close();
return found;
system("CLS");
fstream fl(FLBSTUD,ios::in|ios::ate|ios::binary);
return 0;
fl.close();
fl.open(FLBSTUD,ios::in|ios::binary);
char ch;
char query[30];
Student obj;
int found = 0;
cout<<" (T)itle.\n";
cout<<" (N)ame of Student.\n";
cout<<" (A)ddress.\n";
do{
cin>>ch;
ch = toupper(ch);
do{
gets(query);
}while(strlen(query)==0);
while(!fl.eof()){
fl.read((char*)&obj,sizeof(obj));
if(fl.eof()){
break;
if((strcmpi(query,obj.retString(ch))==0)){
if(!found)
obj.printDetails();
RULE('-');
found = 1;
if(!found)
fl.close();
return found;
int searchByRollNo(int i){ //Search Record by Roll No., 1 for Class, 2 for
Student
system("CLS");
int r;
if(i==1){
Class obj;
int found = 0;
int cl;
do{
cin>>cl;
}while(cl>12 || cl<0);
cin>>r;
fstream fl(FLBCLAS,ios::in|ios::binary);
return 0;
while(!fl.eof()){
fl.read((char*)&obj,sizeof(obj));
if(fl.eof()){
break;
if(CL(cl,obj.retClass())){
if(!found)
RULE('-');
found = 1;
if(!found)
fl.close();
return found;
else{
int found=0;
Student obj;
cin>>r;
fstream fl(FLBSTUD,ios::in|ios::binary);
return 0;
while(!fl.eof()){
fl.read((char*)&obj,sizeof(obj));
if(fl.eof()){
break;
if(r==obj.retRollNo()){
if(!found)
obj.printDetails();
RULE('-');
found = 1;
if(!found)
fl.close();
return found;
int i;
Class obj;
int v=0;
if(!fl){
return;
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
v=1;
fl.close();
if(v==0){
return;
}
fstream tmp("temp.txt",ios::out|ios::binary);
fl.open(FLBCLAS,ios::in|ios::binary);
fl.seekg(0,ios::beg);
for(i=0;i<lst.size();i++){
fl.close();
fl.open(FLBCLAS,ios::in|ios::binary);
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
tmp.write((char*)&obj,sizeof(obj));
fl.close();
tmp.close();
remove(FLBCLAS);
rename("temp.txt",FLBCLAS);
dispClassRecord();
Student obj;
int v=0;
char c;
system("CLS");
cout<<"Enter criteria to sort :\n";
cout<<" (T)itle.\n";
do{
cin>>c;
c=toupper(c);
if(!fl){
return;
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
v=1;
fl.close();
if(v==0){
return;
fstream tmp("temp.txt",ios::out|ios::binary);
fl.open(FLBSTUD,ios::in|ios::binary);
fl.seekg(0,ios::beg);
for(i=0;i<lst.size();i++){
fl.close();
fl.open(FLBSTUD,ios::in|ios::binary);
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
tmp.write((char*)&obj,sizeof(obj));
fl.close();
tmp.close();
remove(FLBSTUD);
rename("temp.txt",FLBSTUD);
dispStudentRecord();
system("CLS");
int f=0;
if(!searchClassID("delete from"))
return;
int r;
char ch;
cin>>r;
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
if (r==obj.retRollNo()){
obj.printDetails();
do{
cin>>ch;
ch = toupper(ch);
if(ch=='N'){
fl.close();
fo.close();
remove("temp.dat");
return;
f=1;
continue;
fo.write((char*)&obj,sizeof(obj));
fl.close();
fo.close();
remove(FLBCLAS);
rename("temp.dat",FLBCLAS);
if(f)
else
system("CLS");
int f=0;
if(!searchStudentID("delete using"))
return;
int r;
char ch;
cin>>r;
while(!fl.eof()){
fl.read((char*)&obj, sizeof(obj));
if(fl.eof())
break;
if (r==obj.retRollNo()){
obj.printDetails();
do{
cin>>ch;
ch = toupper(ch);
if(ch=='N'){
fl.close();
fo.close();
remove("temp.dat");
return;
f=1;
continue;
fo.write((char*)&obj,sizeof(obj));
fl.close();
fo.close();
remove(FLBSTUD);
rename("temp.dat",FLBSTUD);
if(f)
else
}int main(){
char ch;
char ch1;
int ch2;
load();
do{
CLS();
RULE("*");
RULE("*");
cout<<"\t0. Exit.\n\n";
fflush(stdin);
cin>>ch1;
if(ch1=='1'){
fflush(stdin);
load();
do{
CLS();
RULE("*");
RULE("*");
RULE('-');
cout<<"\t0. Exit.\n";
ch2 = scan();
switch(ch2){
case 1:
insertStudent();
break;
case 2:
dispStudentRecord();
break;
case 3:
searchByRollNo(2);
break;
case 4:
searchStudentID();
break;
case 5:
sortByStudents('S');
break;
case 6:
modEntry('S');
break;
case 7:
delStudentRecord();
break;
fflush(stdin);
if(ch2)
cin>>ch;
else
load();
}while(ch2!=0);
if(ch1=='2'){
fflush(stdin);
load();
do{
CLS();
RULE("*");
RULE("*");
RULE('-');
cout<<"\t1. Insert Records.\n";
cout<<"\t0. Exit.\n";
ch2 = scan();
switch(ch2){
case 1:
insertClass();
break;
case 2:
dispClassRecord();
break;
case 3:
searchByRollNo(1);
break;
case 4:
searchClassID();
break;
case 5:
sortByStudents('C');
break;
case 6:
modEntry('C');
break;
case 7:
delClassRecord();
break;
case 8:
checkNoInClass();
break;
case 9:
dispByStandard();
break;
case 10:
totalRevenueGenerated();
break;
fflush(stdin);
if(ch2)
cin>>ch;
else{
load();
}while(ch2!=0);
}while(ch1!='0');
CLS();