SlideShare uma empresa Scribd logo
1 de 13
#include<iostream> 
#include<conio.h> 
#include<process.h> 
#include<windows.h> 
#include<string.h> 
#include<stdio.h> 
#include<fstream> 
using namespace std; 
void student_input(char); 
void student_output(char); 
void st_delete(char); 
void modify(char); 
void tfileinput(); 
void ttmodify() ; 
void tfileoutput(); 
void tdelet(); 
class student 
{ 
int rollno , year ; 
// student data to be entered 
long long contactno; 
char name[40] , father_name[50] , gender ,course[50] ,dob[20] , 
hometown[50] ; 
public: 
student(); 
void input(); 
void output(); 
void smodify(); 
int getrollno(); 
void menu(); 
void displaylist(); 
}; 
class teacher 
{ 
int teacher_id , age; 
float salary; 
//teacher data to be entered 
char name[40] , gender , subject[70]; 
public: 
teacher(); 
void input(); 
void output(); 
void tmodify(); 
int get_teacher_id(); 
void menu(); 
void displaylist(); 
}; 
/****************************************STUDENT 
CONSTRUCTOR***************************************/ 
student::student() 
{ 
rollno=year=contactno=0; 
strcpy(name,"NULL"); 
strcpy(father_name,"NULL"); 
strcpy(course,"NULL"); 
strcpy(course,"NULL"); 
strcpy(dob,"NULL"); 
strcpy(hometown,"NULL"); 
gender='0'; 
} 
/********************************************TEACHER 
CONSTRUCTOR*******************************************************/ 
teacher::teacher()
{ 
teacher_id=age=salary=0; 
strcpy(name,"NULL"); 
gender='0'; 
strcpy(subject,"NULL"); 
} 
void display() 
{ 
for(int i=0;i<3;i++) 
{ 
cout<<"nnnttSTUDENT AND TEACHER DATABASEn"; 
cout<<"nnnntttLOADINGt"; 
for(int j=0;j<3;j++) 
{ 
cout<<" . "; 
Sleep(350); 
} 
system("cls"); 
} 
} 
/***********************************STUDENT 
MENU********************************************************************/ 
void student::menu() 
{ 
char c,ch,n; 
system("cls"); 
cout<<"ntEnter year whose records to be maintainednFor First year press 
1nFor Second year press 2nFor Third year press 3n"; 
cin>>n; 
do 
{ 
system("cls"); 
cout<<"ntttEnter choice:n"; 
cout<<"ntt1. Student Detailsn"; 
cout<<"ntt2. Add new recordn"; 
cout<<"ntt3. Modify a recordn"; 
cout<<"ntt4. Delete a recordn"; 
cout<<"ntt5. Return to main menun"; 
cout<<"ntt6. Exit from programn"; 
cin>>c; 
cout<<"n"; 
switch(c) 
{ 
case '1': student_output(n); 
break; 
case '2': student_input(n); 
break; 
case '3': modify(n); 
break; 
case '4': st_delete(n); 
break; 
case '5': return; 
case '6': system("cls"); 
cout<<"nHave a nice day :)n";
getch(); 
exit(0); 
} 
cout<<"ntDo you want to continuen"; 
cin>>ch; 
}while(ch=='y'||ch=='Y'); 
} 
/***********************************TEACHER 
MENU********************************************************************/ 
void teacher::menu() 
{ 
char c,ch; 
do 
{ 
system("cls"); 
cout<<"nttEnter choice:n"; 
cout<<"ntt1. Teacher Detailsn"; 
cout<<"ntt2. Add new recordn"; 
cout<<"ntt3. Modify a recordn"; 
cout<<"ntt4. Delete a recordn"; 
cout<<"ntt5. Return to main menun"; 
cout<<"ntt6. Exit from programn"; 
cin>>c;cout<<"n"; 
switch(c) 
{ 
case '1': tfileoutput(); 
break; 
case '2': tfileinput(); 
break; 
case '3': ttmodify(); 
break; 
case '4': tdelet(); 
break; 
case '5': return ; 
case '6': system("cls"); 
cout<<"nHave a nice day :)n"; 
getch(); 
exit(0); 
} 
cout<<"ntDo you want to continuen"; 
cin>>ch; 
}while(ch=='y'||ch=='Y'); 
} 
void student_input(char q) 
//writing student records in file 
{ 
student s; 
int n; 
ofstream fout; 
cout<<"nHow many records do u want to Entern"; 
cin>>n; 
switch(q) 
{ 
case '1':fout.open("stud1.txt",ios::app);
break; 
case '2':fout.open("stud2.txt",ios::app); 
break; 
case '3':fout.open("stud3.txt",ios::app); 
break; 
} 
while(n--) 
{ 
s.input(); 
fout.write((char*)(&s),sizeof(s)); 
} 
fout.close(); 
} 
void tfileinput() 
//writing teacher record in file 
{ 
teacher t; 
int n; 
ofstream fout; 
cout<<"nHow many records do u want to entern"; 
cin>>n; 
fout.open("teacher.txt",ios::app); 
while(n--) 
{ 
t.input(); 
fout.write((char*)(&t),sizeof(t)); 
} 
fout.close(); 
} 
void student::displaylist() 
//STUDENT DISPLAY LIST 
{ 
cout<<rollno<<"tt"<<name<<"n"; 
} 
void teacher::displaylist() 
//TEACHER DISPLAY LIST 
{ 
cout<<teacher_id<<"tt"<<name<<"n"; 
} 
void student_output(char q) 
{ 
system("cls"); 
ifstream fin; 
//output 
student 
student s; 
int f=0; 
switch(q) 
{ 
case '1': fin.open("stud1.txt"); 
break; 
case '2': fin.open("stud2.txt");
break; 
case '3': fin.open("stud3.txt"); 
break; 
} 
cout<<"ntttSTUDENT LISTn"<<"nRoll No. "<<"t Namen"; 
while(fin.read((char*)(&s),sizeof(s))) 
//To print student details list 
s.displaylist(); 
int n; 
fin.close(); 
switch(q) 
{ 
case '1':fin.open("stud1.txt"); 
break; 
case '2':fin.open("stud2.txt"); 
break; 
case '3':fin.open("stud3.txt"); 
break; 
} 
cout<<"nnttEnter Roll no. whose record you want to See ('-1' to go back 
to previous menu)n"; 
cin>>n; 
if(n==-1) 
{ 
system("cls"); 
return; 
} 
system("cls"); 
while(fin.read((char*)(&s),sizeof(s))) 
//To print student file details 
{ 
if(n==s.getrollno()) 
{ 
s.output(); 
f=1; 
} 
} 
if(f==0) 
cout<<"nStudent record not found !!!n"; 
fin.close(); 
} 
/***************************TEACHER READ FROM FILE 
FUNCTION******************************************************************/ 
void tfileoutput() 
{ 
system("cls"); 
ifstream fin; 
teacher t; 
int f=0; 
fin.open("teacher.txt"); 
cout<<"ttTEACHER LISTnn"; 
cout<<"IDtt"<<"Namenn"; 
while(fin.read((char*)(&t),sizeof(t))) 
t.displaylist(); 
int n; 
fin.close(); 
cout<<"nnEnter Teacher ID whose record you want to see ('-1' to go back to
previous menu)n"; 
cin>>n; 
if(n==-1) 
{ 
system("cls"); 
return; 
} 
system("cls"); 
fin.open("teacher.txt"); 
while(fin.read((char*)(&t),sizeof(t))) 
{ 
if(n==t.get_teacher_id()) 
{ 
t.output(); 
f=1; 
} 
} 
if(f==0) 
cout<<"nEntered ID not Foundn"; 
fin.close(); 
} 
/************************************STUDENT MODIFY 
FUNCTION************************************************/ 
void modify(char q) 
{ 
fstream fio; 
switch(q) 
{ 
case '1':fio.open("stud1.txt"); 
break; 
case '2':fio.open("stud2.txt"); 
break; 
case '3':fio.open("stud3.txt"); 
break; 
} 
int no; 
long pos; 
student s; 
char found='f'; 
cout<<"nntEnter the roll no. whose record is to be modified n "; 
cin>>no; 
fio.seekg(0); 
while(!fio.eof()) 
{ 
pos=fio.tellg(); 
fio.read((char *)&s, sizeof(s)); 
if(s.getrollno()==no) 
{ 
fio.seekg(pos); 
system("cls"); 
s.output(); 
s.smodify(); 
fio.write((char*) &s, sizeof(s)); 
found='t'; 
break ; 
} 
} 
if(found=='f') 
cout<<"nntRecord not found !!n"; 
fio.close(); 
getch();
} 
void student::smodify() 
{ 
int srollno , syear ; // 
temporary data storages 
long long scontactno; 
char sname[40] , sfather_name[50] , sgender , scourse[50] , sdob[20] , 
shometown[50] ; 
cout<<"nEnter New Detailsn"; 
cout<<"nRoll No. (-1 to retain old one)n"; 
cin>>srollno; 
cout<<"nName ('.' to retain old one )n"; 
cin.ignore(40,'n'); 
cin.getline(sname,40,'n'); 
cout<<"nFather'sName ('.' to retain old one )n"; 
//cin.ignore(40,'n'); 
cin.getline(sfather_name,40,'n'); 
cout<<"nDate of birth ('.' to retain old one )n"; 
cin.getline(sdob,20,'n'); 
cout<<"nGender (M/F) ('.' to retain old one )n"; 
cin>>sgender; 
cout<<"nContact no. (-1 to retain old one)n"; 
cin>>scontactno; 
cout<<"nCourse ('.' to retain old one )n"; 
cin.ignore(50,'n'); 
cin.getline(scourse,50,'n'); 
cout<<"nHometown ('.' to retain old one )n"; 
//cin.ignore(50,'n'); 
cin.getline(shometown,50,'n'); 
cout<<"Year (-1 to retain old one)n"; 
cin>>syear; 
if(srollno != -1) 
rollno=srollno; 
if(scontactno != -1) 
contactno=scontactno; 
if(syear != -1) 
year=syear; 
if(strcmp(sname,".") != 0) 
strcpy(name,sname); 
if(sgender != '.') 
gender=sgender; 
if(strcmp(sfather_name,".") != 0) 
strcpy(father_name,sfather_name); 
if(strcmp(shometown,".") != 0) 
strcpy(hometown,shometown); 
if(strcmp(sdob,".") != 0)
strcpy(dob,sdob); 
if(strcmp(scourse,".") != 0) 
strcpy(course,scourse); 
} 
/*************************************************TEACHER MODIFY 
FUNCTION*******************************************************/ 
void ttmodify() 
{ 
system(" cls "); 
fstream fio; 
int no; 
long pos; 
teacher t; 
char found='f'; 
fio.open("teacher.txt",ios::in|ios::out); 
cout<<"nntEnter the ID whose record is to be modified n "; 
cin>>no; 
fio.seekg(0); 
while(!fio.eof()) 
{ 
pos=fio.tellg(); 
fio.read((char *)&t, sizeof(t)); 
if(t.get_teacher_id()==no) 
{ 
fio.seekg(pos); 
system("cls"); 
t.output(); 
t.tmodify(); 
fio.write((char*) &t, sizeof(t)); 
found='t'; 
break ; 
} 
} 
if(found=='f') 
cout<<"nntRecord not found !!n"; 
fio.close(); 
getch(); 
} 
void teacher::tmodify() 
{ 
int tteacher_id , tage; 
float tsalary; 
//temporary teacher data to be entered 
char tname[40] , tgender , tsubject[70]; 
cout<<"nnEnter New Detailsnn"; 
cout<<"Enter New Teacher ID ('-1' to retain old one )n"; 
cin>>tteacher_id; 
cout<<"nName ('.' to retain old one )n"; 
cin.ignore(40,'n'); 
cin.getline(tname,40,'n'); 
cout<<"nAge ('-1' to retain old one )n"; 
cin>>tage; 
cout<<"nEnter gender(M/F) ('.' to retain old one )n"; 
cin>>tgender; 
cout<<"nEnter Subject ('.' to retain old one )n";
cin.ignore(40,'n'); 
cin.getline(tsubject,70,'n'); 
cout<<"nEnter salary ('-1' to retain old one )n"; 
cin>>tsalary; 
if(tteacher_id != -1) 
teacher_id=tteacher_id; 
if(strcmp(tname,".") != 0) 
strcpy(name,tname); 
if(strcmp(tsubject,".") != 0) 
strcpy(subject,tsubject); 
if(tsalary != -1) 
salary=tsalary; 
if(tage != -1) 
age=tage; 
if(tgender != '.') 
gender=tgender; 
} 
/*************************************STUDENT RECORD DELETE FUNCTION 
FUNCTION*********************************************/ 
void st_delete(char q) 
{ 
int n; 
char ch,f; 
student s; 
ifstream fin; 
ofstream fout; 
fout.open("temp.txt"); 
switch(q) 
{ 
case '1':fin.open("stud1.txt"); 
break; 
case '2':fin.open("stud2.txt"); 
break; 
case '3':fin.open("stud3.txt"); 
break; 
} 
cout<<"nEnter roll no. whose record you want to DELETEn"; 
cin>>n; 
system("cls"); 
while(fin.read((char*)(&s),sizeof(s))) 
{ 
if(n==s.getrollno()) 
{ 
f='y'; 
s.output(); 
cout<<"nCONFIRM DELETE(Y/N)n"; 
cin>>ch; 
if(ch=='y'||ch=='Y') 
{ 
cout<<"nRECORD DELETEDn"; 
getch(); 
continue; 
}
} 
fout.write((char*)&s,sizeof(s)); 
} 
if(f!='y') 
cout<<"nstudent record not foundn"; 
fin.close(); 
fout.close(); 
switch(q) 
{ 
case '1':remove("stud1.txt"); 
rename("temp.txt","stud1.txt"); 
break; 
case '2':remove("stud2.txt"); 
rename("temp.txt","stud2.txt"); 
break; 
case '3':remove("stud3.txt"); 
rename("temp.txt","stud3.txt");; 
break; 
} 
} 
/*************************************TEACHER RECORD DELETE FUNCTION 
FUNCTION*********************************************/ 
void tdelet() 
{ int n; 
char ch,f; 
teacher t; 
ifstream fin; 
ofstream fout; 
fin.open("teacher.txt"); 
fout.open("temp.txt"); 
cout<<"nttEnter Teacher id whose record you want to DELETEn"; 
cin>>n; 
system("cls"); 
while(fin.read((char*)(&t),sizeof(t))) 
{if(n==t.get_teacher_id()) 
{ f='y'; 
t.output(); 
cout<<"nCONFIRM DELETE(Y/N)n"; 
cin>>ch; 
if(ch=='y'||ch=='Y') 
{ 
cout<<"nRECORD DELETEDn"; 
getch(); 
continue; 
} 
} 
fout.write((char*)&t,sizeof(t)); 
} 
if(f!='y') 
cout<<"nteacher record not foundn"; 
fin.close(); 
fout.close(); 
remove("teacher.txt"); 
rename("temp.txt","teacher.txt"); 
} 
/**********************************STUDENT DATA INPUT 
FUNCTION**************************************************************/ 
void student::input() 
{
system("cls"); 
cout<<"Enter Roll No.n"; 
cin>>rollno; 
cout<<"nEnter Name n"; 
cin.ignore(40,'n'); 
cin.getline(name,40,'n'); 
cout<<"nFather's namen"; 
cin.getline(father_name,50,'n'); 
cout<<"nEnter Date of birthn"; 
cin.getline(dob,20,'n'); 
cout<<"nEnter Gender(M/F)n"; 
cin>>gender; 
cout<<"nEnter Contact no.n"; 
cin>>contactno; 
cout<<"nHometownn"; 
cin.ignore(50,'n'); 
cin.getline(hometown,50,'n'); 
cout<<"nEnter Coursen"; 
cin.getline(course,50,'n'); 
cout<<"nEnter year of admissionn"; 
cin>>year; 
} 
/*************************************STUDENT OUTPUT 
FUNCTION*******************************************/ 
void student::output() 
{ 
cout<<"tttSTUDENT DETAILSn" ; 
cout<<"nttRoll No.t"; 
cout<<rollno; 
cout<<"nnttName tt"; 
cout<<name; 
cout<<"nnttFather's namet"; 
cout<<father_name; 
cout<<"nnttGendertt"; 
cout<<gender<<endl; 
cout<<"nttContact No.t"; 
cout<<contactno; 
cout<<"nnttHometownt"; 
cout<<hometown; 
cout<<"nnttCoursett"; 
cout<<course<<endl; 
cout<<"nttYeartt"; 
cout<<year<<endl; 
} 
/*************************************TEACHER INPUT 
FUNCTION*******************************************/ 
void teacher::input() 
{
system("cls"); 
cout<<"Enter Teacher IDn"; 
cin>>teacher_id; 
cout<<"nEnter Name n"; 
cin.ignore(40,'n'); 
cin.getline(name,40,'n'); 
cout<<"nEnter agen"; 
cin>>age; 
cout<<"nEnter gender(M/F)n"; 
cin>>gender; 
cout<<"nEnter Subjectn"; 
cin.ignore(40,'n'); 
cin.getline(subject,70,'n'); 
cout<<"nEnter salaryn"; 
cin>>salary; 
} 
/*************************************TEACHER OUTPUT 
FUNCTION*******************************************/ 
void teacher::output() 
{ 
system("cls"); 
cout<<"ntttTEACHER DETAILSn"; 
cout<<"nttTeacher IDt"<<teacher_id; 
cout<<"nnttName tt"<<name<<"n"; 
cout<<"nttAgett"<<age<<"n"; 
cout<<"nttGendertt"<<gender<<"n"; 
cout<<"nttSubjecttt"<<subject<<"n"; 
cout<<"nttSalaryttRs."<<salary<<"n"; 
} 
int teacher::get_teacher_id() 
//Reutrning teacher id 
{return teacher_id;} 
int student::getrollno() 
//Returning student roll no. 
{return rollno;} 
int main() //MAIN 
FUNCTION 
{ 
display(); 
student s; 
teacher t; 
int c,ch; 
do{ 
system("cls"); 
cout<<"ntttMain Menu n" ; 
cout<<"nttEnter choice whose data to be maintainedn"; 
cout<<"ntt1. Studentn"; 
cout<<"ntt2. Teachern"; 
cout<<"ntt3. Exitn"; 
cin>>c; 
cout<<"n"; 
switch(c) 
{case 1:s.menu(); 
break;
case 2:t.menu(); 
break; 
case 3:cout<<"nHave a Nice Day :)n"; 
getch(); 
exit(0); 
} 
}while(1); 
getch(); 
}

Mais conteúdo relacionado

Mais procurados

81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programsAbhishek Jena
 
Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Rushil Aggarwal
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project D. j Vicky
 
Telephone billing system in c++
Telephone billing system in c++Telephone billing system in c++
Telephone billing system in c++vikram mahendra
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)Nitish Yadav
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THSHAJUS5
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 
Investigatory Project for Computer Science
Investigatory Project for Computer Science Investigatory Project for Computer Science
Investigatory Project for Computer Science Sonali Sinha
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 
C# console programms
C# console programmsC# console programms
C# console programmsYasir Khan
 

Mais procurados (20)

Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
Computer Investgatort Project (HOTEL MANAGEMENT SYSTEM)
 
81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs81818088 isc-class-xii-computer-science-project-java-programs
81818088 isc-class-xii-computer-science-project-java-programs
 
Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++Computer science Investigatory Project Class 12 C++
Computer science Investigatory Project Class 12 C++
 
C++ file
C++ fileC++ file
C++ file
 
Supermarket
SupermarketSupermarket
Supermarket
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
 
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project  cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
 
Telephone billing system in c++
Telephone billing system in c++Telephone billing system in c++
Telephone billing system in c++
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)
 
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12THBANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
Canteen management
Canteen managementCanteen management
Canteen management
 
Investigatory Project for Computer Science
Investigatory Project for Computer Science Investigatory Project for Computer Science
Investigatory Project for Computer Science
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
C# console programms
C# console programmsC# console programms
C# console programms
 
C++ TUTORIAL 10
C++ TUTORIAL 10C++ TUTORIAL 10
C++ TUTORIAL 10
 

Destaque

Musical Instrumental Management
Musical Instrumental ManagementMusical Instrumental Management
Musical Instrumental ManagementMahendra Sundesha
 
Teacher management system guide
Teacher management system guideTeacher management system guide
Teacher management system guidenicolasmunozvera
 
Instrumental delivery
Instrumental deliveryInstrumental delivery
Instrumental deliverymagdy abdel
 
Quản lý học sinh và giáo viên trong một trường phổ thông
Quản lý học sinh và giáo viên trong một trường phổ thôngQuản lý học sinh và giáo viên trong một trường phổ thông
Quản lý học sinh và giáo viên trong một trường phổ thôngBent Nc
 
Assisted vaginal delivery
Assisted vaginal deliveryAssisted vaginal delivery
Assisted vaginal deliveryWaill Altimeemi
 
Vacuum Delivery OSCE
Vacuum Delivery OSCEVacuum Delivery OSCE
Vacuum Delivery OSCEnicoletanww
 
Instrumental vaginaldelivery...
Instrumental  vaginaldelivery...Instrumental  vaginaldelivery...
Instrumental vaginaldelivery...imanswati
 
Vacuum extraction (ventouse)
Vacuum extraction (ventouse)Vacuum extraction (ventouse)
Vacuum extraction (ventouse)raj kumar
 
Forceps delivery
Forceps deliveryForceps delivery
Forceps deliveryraj kumar
 
Thesis computerized grading system
Thesis computerized grading systemThesis computerized grading system
Thesis computerized grading systemjolensreyes
 
Instrumental deliveries
Instrumental deliveriesInstrumental deliveries
Instrumental deliveriesdrmcbansal
 
Operative obstetrics
Operative obstetricsOperative obstetrics
Operative obstetricsAlan Mathew
 
Computerized grading system chapter 1-3
Computerized grading system chapter 1-3Computerized grading system chapter 1-3
Computerized grading system chapter 1-3Chriselle24
 
School Management System ppt
School Management System pptSchool Management System ppt
School Management System pptMohsin Ali
 
Thesis in IT Online Grade Encoding and Inquiry System via SMS Technology
Thesis in IT Online Grade Encoding and Inquiry System via SMS TechnologyThesis in IT Online Grade Encoding and Inquiry System via SMS Technology
Thesis in IT Online Grade Encoding and Inquiry System via SMS TechnologyBelLa Bhe
 

Destaque (17)

Musical Instrumental Management
Musical Instrumental ManagementMusical Instrumental Management
Musical Instrumental Management
 
Teacher management system guide
Teacher management system guideTeacher management system guide
Teacher management system guide
 
Instrumental delivery
Instrumental deliveryInstrumental delivery
Instrumental delivery
 
Quản lý học sinh và giáo viên trong một trường phổ thông
Quản lý học sinh và giáo viên trong một trường phổ thôngQuản lý học sinh và giáo viên trong một trường phổ thông
Quản lý học sinh và giáo viên trong một trường phổ thông
 
Assisted vaginal delivery
Assisted vaginal deliveryAssisted vaginal delivery
Assisted vaginal delivery
 
Vacuum Delivery OSCE
Vacuum Delivery OSCEVacuum Delivery OSCE
Vacuum Delivery OSCE
 
Instrumental vaginaldelivery...
Instrumental  vaginaldelivery...Instrumental  vaginaldelivery...
Instrumental vaginaldelivery...
 
It sba 2015
It sba 2015It sba 2015
It sba 2015
 
Vacuum extraction (ventouse)
Vacuum extraction (ventouse)Vacuum extraction (ventouse)
Vacuum extraction (ventouse)
 
Forceps delivery
Forceps deliveryForceps delivery
Forceps delivery
 
Thesis computerized grading system
Thesis computerized grading systemThesis computerized grading system
Thesis computerized grading system
 
Instrumental deliveries
Instrumental deliveriesInstrumental deliveries
Instrumental deliveries
 
Forceps
ForcepsForceps
Forceps
 
Operative obstetrics
Operative obstetricsOperative obstetrics
Operative obstetrics
 
Computerized grading system chapter 1-3
Computerized grading system chapter 1-3Computerized grading system chapter 1-3
Computerized grading system chapter 1-3
 
School Management System ppt
School Management System pptSchool Management System ppt
School Management System ppt
 
Thesis in IT Online Grade Encoding and Inquiry System via SMS Technology
Thesis in IT Online Grade Encoding and Inquiry System via SMS TechnologyThesis in IT Online Grade Encoding and Inquiry System via SMS Technology
Thesis in IT Online Grade Encoding and Inquiry System via SMS Technology
 

Semelhante a Student teacher database management

IN C LANGUAGE- I've been trying to finish this program for the last fe.docx
IN C LANGUAGE- I've been trying to finish this program for the last fe.docxIN C LANGUAGE- I've been trying to finish this program for the last fe.docx
IN C LANGUAGE- I've been trying to finish this program for the last fe.docxGordonpACKellyb
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 UsageWilliam Lee
 
Zoo management adri jovin
Zoo management  adri jovinZoo management  adri jovin
Zoo management adri jovinAdri Jovin
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)Ankit Gupta
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11nbb3i
 
Institute management
Institute managementInstitute management
Institute managementvarun arora
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
java-introduction.pdf
java-introduction.pdfjava-introduction.pdf
java-introduction.pdfDngTin307322
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmhome
 
Project hotel on hotel management fo
Project  hotel on hotel management foProject  hotel on hotel management fo
Project hotel on hotel management foSunny Singhania
 

Semelhante a Student teacher database management (20)

IN C LANGUAGE- I've been trying to finish this program for the last fe.docx
IN C LANGUAGE- I've been trying to finish this program for the last fe.docxIN C LANGUAGE- I've been trying to finish this program for the last fe.docx
IN C LANGUAGE- I've been trying to finish this program for the last fe.docx
 
Tu1
Tu1Tu1
Tu1
 
Notes for SQLite3 Usage
Notes for SQLite3 UsageNotes for SQLite3 Usage
Notes for SQLite3 Usage
 
Zoo management adri jovin
Zoo management  adri jovinZoo management  adri jovin
Zoo management adri jovin
 
Vcs29
Vcs29Vcs29
Vcs29
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)
 
Data Structure
Data StructureData Structure
Data Structure
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11
 
Bubble Sort
Bubble SortBubble Sort
Bubble Sort
 
Institute management
Institute managementInstitute management
Institute management
 
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfI need to fill-in TODOs in .cpp file and in .h file Could some.pdf
I need to fill-in TODOs in .cpp file and in .h file Could some.pdf
 
Data structures
Data structuresData structures
Data structures
 
About Go
About GoAbout Go
About Go
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
C program
C programC program
C program
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Java
JavaJava
Java
 
java-introduction.pdf
java-introduction.pdfjava-introduction.pdf
java-introduction.pdf
 
Student DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEmStudent DATABASE MANAGeMEnT SysTEm
Student DATABASE MANAGeMEnT SysTEm
 
Project hotel on hotel management fo
Project  hotel on hotel management foProject  hotel on hotel management fo
Project hotel on hotel management fo
 

Último

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Último (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

Student teacher database management

  • 1. #include<iostream> #include<conio.h> #include<process.h> #include<windows.h> #include<string.h> #include<stdio.h> #include<fstream> using namespace std; void student_input(char); void student_output(char); void st_delete(char); void modify(char); void tfileinput(); void ttmodify() ; void tfileoutput(); void tdelet(); class student { int rollno , year ; // student data to be entered long long contactno; char name[40] , father_name[50] , gender ,course[50] ,dob[20] , hometown[50] ; public: student(); void input(); void output(); void smodify(); int getrollno(); void menu(); void displaylist(); }; class teacher { int teacher_id , age; float salary; //teacher data to be entered char name[40] , gender , subject[70]; public: teacher(); void input(); void output(); void tmodify(); int get_teacher_id(); void menu(); void displaylist(); }; /****************************************STUDENT CONSTRUCTOR***************************************/ student::student() { rollno=year=contactno=0; strcpy(name,"NULL"); strcpy(father_name,"NULL"); strcpy(course,"NULL"); strcpy(course,"NULL"); strcpy(dob,"NULL"); strcpy(hometown,"NULL"); gender='0'; } /********************************************TEACHER CONSTRUCTOR*******************************************************/ teacher::teacher()
  • 2. { teacher_id=age=salary=0; strcpy(name,"NULL"); gender='0'; strcpy(subject,"NULL"); } void display() { for(int i=0;i<3;i++) { cout<<"nnnttSTUDENT AND TEACHER DATABASEn"; cout<<"nnnntttLOADINGt"; for(int j=0;j<3;j++) { cout<<" . "; Sleep(350); } system("cls"); } } /***********************************STUDENT MENU********************************************************************/ void student::menu() { char c,ch,n; system("cls"); cout<<"ntEnter year whose records to be maintainednFor First year press 1nFor Second year press 2nFor Third year press 3n"; cin>>n; do { system("cls"); cout<<"ntttEnter choice:n"; cout<<"ntt1. Student Detailsn"; cout<<"ntt2. Add new recordn"; cout<<"ntt3. Modify a recordn"; cout<<"ntt4. Delete a recordn"; cout<<"ntt5. Return to main menun"; cout<<"ntt6. Exit from programn"; cin>>c; cout<<"n"; switch(c) { case '1': student_output(n); break; case '2': student_input(n); break; case '3': modify(n); break; case '4': st_delete(n); break; case '5': return; case '6': system("cls"); cout<<"nHave a nice day :)n";
  • 3. getch(); exit(0); } cout<<"ntDo you want to continuen"; cin>>ch; }while(ch=='y'||ch=='Y'); } /***********************************TEACHER MENU********************************************************************/ void teacher::menu() { char c,ch; do { system("cls"); cout<<"nttEnter choice:n"; cout<<"ntt1. Teacher Detailsn"; cout<<"ntt2. Add new recordn"; cout<<"ntt3. Modify a recordn"; cout<<"ntt4. Delete a recordn"; cout<<"ntt5. Return to main menun"; cout<<"ntt6. Exit from programn"; cin>>c;cout<<"n"; switch(c) { case '1': tfileoutput(); break; case '2': tfileinput(); break; case '3': ttmodify(); break; case '4': tdelet(); break; case '5': return ; case '6': system("cls"); cout<<"nHave a nice day :)n"; getch(); exit(0); } cout<<"ntDo you want to continuen"; cin>>ch; }while(ch=='y'||ch=='Y'); } void student_input(char q) //writing student records in file { student s; int n; ofstream fout; cout<<"nHow many records do u want to Entern"; cin>>n; switch(q) { case '1':fout.open("stud1.txt",ios::app);
  • 4. break; case '2':fout.open("stud2.txt",ios::app); break; case '3':fout.open("stud3.txt",ios::app); break; } while(n--) { s.input(); fout.write((char*)(&s),sizeof(s)); } fout.close(); } void tfileinput() //writing teacher record in file { teacher t; int n; ofstream fout; cout<<"nHow many records do u want to entern"; cin>>n; fout.open("teacher.txt",ios::app); while(n--) { t.input(); fout.write((char*)(&t),sizeof(t)); } fout.close(); } void student::displaylist() //STUDENT DISPLAY LIST { cout<<rollno<<"tt"<<name<<"n"; } void teacher::displaylist() //TEACHER DISPLAY LIST { cout<<teacher_id<<"tt"<<name<<"n"; } void student_output(char q) { system("cls"); ifstream fin; //output student student s; int f=0; switch(q) { case '1': fin.open("stud1.txt"); break; case '2': fin.open("stud2.txt");
  • 5. break; case '3': fin.open("stud3.txt"); break; } cout<<"ntttSTUDENT LISTn"<<"nRoll No. "<<"t Namen"; while(fin.read((char*)(&s),sizeof(s))) //To print student details list s.displaylist(); int n; fin.close(); switch(q) { case '1':fin.open("stud1.txt"); break; case '2':fin.open("stud2.txt"); break; case '3':fin.open("stud3.txt"); break; } cout<<"nnttEnter Roll no. whose record you want to See ('-1' to go back to previous menu)n"; cin>>n; if(n==-1) { system("cls"); return; } system("cls"); while(fin.read((char*)(&s),sizeof(s))) //To print student file details { if(n==s.getrollno()) { s.output(); f=1; } } if(f==0) cout<<"nStudent record not found !!!n"; fin.close(); } /***************************TEACHER READ FROM FILE FUNCTION******************************************************************/ void tfileoutput() { system("cls"); ifstream fin; teacher t; int f=0; fin.open("teacher.txt"); cout<<"ttTEACHER LISTnn"; cout<<"IDtt"<<"Namenn"; while(fin.read((char*)(&t),sizeof(t))) t.displaylist(); int n; fin.close(); cout<<"nnEnter Teacher ID whose record you want to see ('-1' to go back to
  • 6. previous menu)n"; cin>>n; if(n==-1) { system("cls"); return; } system("cls"); fin.open("teacher.txt"); while(fin.read((char*)(&t),sizeof(t))) { if(n==t.get_teacher_id()) { t.output(); f=1; } } if(f==0) cout<<"nEntered ID not Foundn"; fin.close(); } /************************************STUDENT MODIFY FUNCTION************************************************/ void modify(char q) { fstream fio; switch(q) { case '1':fio.open("stud1.txt"); break; case '2':fio.open("stud2.txt"); break; case '3':fio.open("stud3.txt"); break; } int no; long pos; student s; char found='f'; cout<<"nntEnter the roll no. whose record is to be modified n "; cin>>no; fio.seekg(0); while(!fio.eof()) { pos=fio.tellg(); fio.read((char *)&s, sizeof(s)); if(s.getrollno()==no) { fio.seekg(pos); system("cls"); s.output(); s.smodify(); fio.write((char*) &s, sizeof(s)); found='t'; break ; } } if(found=='f') cout<<"nntRecord not found !!n"; fio.close(); getch();
  • 7. } void student::smodify() { int srollno , syear ; // temporary data storages long long scontactno; char sname[40] , sfather_name[50] , sgender , scourse[50] , sdob[20] , shometown[50] ; cout<<"nEnter New Detailsn"; cout<<"nRoll No. (-1 to retain old one)n"; cin>>srollno; cout<<"nName ('.' to retain old one )n"; cin.ignore(40,'n'); cin.getline(sname,40,'n'); cout<<"nFather'sName ('.' to retain old one )n"; //cin.ignore(40,'n'); cin.getline(sfather_name,40,'n'); cout<<"nDate of birth ('.' to retain old one )n"; cin.getline(sdob,20,'n'); cout<<"nGender (M/F) ('.' to retain old one )n"; cin>>sgender; cout<<"nContact no. (-1 to retain old one)n"; cin>>scontactno; cout<<"nCourse ('.' to retain old one )n"; cin.ignore(50,'n'); cin.getline(scourse,50,'n'); cout<<"nHometown ('.' to retain old one )n"; //cin.ignore(50,'n'); cin.getline(shometown,50,'n'); cout<<"Year (-1 to retain old one)n"; cin>>syear; if(srollno != -1) rollno=srollno; if(scontactno != -1) contactno=scontactno; if(syear != -1) year=syear; if(strcmp(sname,".") != 0) strcpy(name,sname); if(sgender != '.') gender=sgender; if(strcmp(sfather_name,".") != 0) strcpy(father_name,sfather_name); if(strcmp(shometown,".") != 0) strcpy(hometown,shometown); if(strcmp(sdob,".") != 0)
  • 8. strcpy(dob,sdob); if(strcmp(scourse,".") != 0) strcpy(course,scourse); } /*************************************************TEACHER MODIFY FUNCTION*******************************************************/ void ttmodify() { system(" cls "); fstream fio; int no; long pos; teacher t; char found='f'; fio.open("teacher.txt",ios::in|ios::out); cout<<"nntEnter the ID whose record is to be modified n "; cin>>no; fio.seekg(0); while(!fio.eof()) { pos=fio.tellg(); fio.read((char *)&t, sizeof(t)); if(t.get_teacher_id()==no) { fio.seekg(pos); system("cls"); t.output(); t.tmodify(); fio.write((char*) &t, sizeof(t)); found='t'; break ; } } if(found=='f') cout<<"nntRecord not found !!n"; fio.close(); getch(); } void teacher::tmodify() { int tteacher_id , tage; float tsalary; //temporary teacher data to be entered char tname[40] , tgender , tsubject[70]; cout<<"nnEnter New Detailsnn"; cout<<"Enter New Teacher ID ('-1' to retain old one )n"; cin>>tteacher_id; cout<<"nName ('.' to retain old one )n"; cin.ignore(40,'n'); cin.getline(tname,40,'n'); cout<<"nAge ('-1' to retain old one )n"; cin>>tage; cout<<"nEnter gender(M/F) ('.' to retain old one )n"; cin>>tgender; cout<<"nEnter Subject ('.' to retain old one )n";
  • 9. cin.ignore(40,'n'); cin.getline(tsubject,70,'n'); cout<<"nEnter salary ('-1' to retain old one )n"; cin>>tsalary; if(tteacher_id != -1) teacher_id=tteacher_id; if(strcmp(tname,".") != 0) strcpy(name,tname); if(strcmp(tsubject,".") != 0) strcpy(subject,tsubject); if(tsalary != -1) salary=tsalary; if(tage != -1) age=tage; if(tgender != '.') gender=tgender; } /*************************************STUDENT RECORD DELETE FUNCTION FUNCTION*********************************************/ void st_delete(char q) { int n; char ch,f; student s; ifstream fin; ofstream fout; fout.open("temp.txt"); switch(q) { case '1':fin.open("stud1.txt"); break; case '2':fin.open("stud2.txt"); break; case '3':fin.open("stud3.txt"); break; } cout<<"nEnter roll no. whose record you want to DELETEn"; cin>>n; system("cls"); while(fin.read((char*)(&s),sizeof(s))) { if(n==s.getrollno()) { f='y'; s.output(); cout<<"nCONFIRM DELETE(Y/N)n"; cin>>ch; if(ch=='y'||ch=='Y') { cout<<"nRECORD DELETEDn"; getch(); continue; }
  • 10. } fout.write((char*)&s,sizeof(s)); } if(f!='y') cout<<"nstudent record not foundn"; fin.close(); fout.close(); switch(q) { case '1':remove("stud1.txt"); rename("temp.txt","stud1.txt"); break; case '2':remove("stud2.txt"); rename("temp.txt","stud2.txt"); break; case '3':remove("stud3.txt"); rename("temp.txt","stud3.txt");; break; } } /*************************************TEACHER RECORD DELETE FUNCTION FUNCTION*********************************************/ void tdelet() { int n; char ch,f; teacher t; ifstream fin; ofstream fout; fin.open("teacher.txt"); fout.open("temp.txt"); cout<<"nttEnter Teacher id whose record you want to DELETEn"; cin>>n; system("cls"); while(fin.read((char*)(&t),sizeof(t))) {if(n==t.get_teacher_id()) { f='y'; t.output(); cout<<"nCONFIRM DELETE(Y/N)n"; cin>>ch; if(ch=='y'||ch=='Y') { cout<<"nRECORD DELETEDn"; getch(); continue; } } fout.write((char*)&t,sizeof(t)); } if(f!='y') cout<<"nteacher record not foundn"; fin.close(); fout.close(); remove("teacher.txt"); rename("temp.txt","teacher.txt"); } /**********************************STUDENT DATA INPUT FUNCTION**************************************************************/ void student::input() {
  • 11. system("cls"); cout<<"Enter Roll No.n"; cin>>rollno; cout<<"nEnter Name n"; cin.ignore(40,'n'); cin.getline(name,40,'n'); cout<<"nFather's namen"; cin.getline(father_name,50,'n'); cout<<"nEnter Date of birthn"; cin.getline(dob,20,'n'); cout<<"nEnter Gender(M/F)n"; cin>>gender; cout<<"nEnter Contact no.n"; cin>>contactno; cout<<"nHometownn"; cin.ignore(50,'n'); cin.getline(hometown,50,'n'); cout<<"nEnter Coursen"; cin.getline(course,50,'n'); cout<<"nEnter year of admissionn"; cin>>year; } /*************************************STUDENT OUTPUT FUNCTION*******************************************/ void student::output() { cout<<"tttSTUDENT DETAILSn" ; cout<<"nttRoll No.t"; cout<<rollno; cout<<"nnttName tt"; cout<<name; cout<<"nnttFather's namet"; cout<<father_name; cout<<"nnttGendertt"; cout<<gender<<endl; cout<<"nttContact No.t"; cout<<contactno; cout<<"nnttHometownt"; cout<<hometown; cout<<"nnttCoursett"; cout<<course<<endl; cout<<"nttYeartt"; cout<<year<<endl; } /*************************************TEACHER INPUT FUNCTION*******************************************/ void teacher::input() {
  • 12. system("cls"); cout<<"Enter Teacher IDn"; cin>>teacher_id; cout<<"nEnter Name n"; cin.ignore(40,'n'); cin.getline(name,40,'n'); cout<<"nEnter agen"; cin>>age; cout<<"nEnter gender(M/F)n"; cin>>gender; cout<<"nEnter Subjectn"; cin.ignore(40,'n'); cin.getline(subject,70,'n'); cout<<"nEnter salaryn"; cin>>salary; } /*************************************TEACHER OUTPUT FUNCTION*******************************************/ void teacher::output() { system("cls"); cout<<"ntttTEACHER DETAILSn"; cout<<"nttTeacher IDt"<<teacher_id; cout<<"nnttName tt"<<name<<"n"; cout<<"nttAgett"<<age<<"n"; cout<<"nttGendertt"<<gender<<"n"; cout<<"nttSubjecttt"<<subject<<"n"; cout<<"nttSalaryttRs."<<salary<<"n"; } int teacher::get_teacher_id() //Reutrning teacher id {return teacher_id;} int student::getrollno() //Returning student roll no. {return rollno;} int main() //MAIN FUNCTION { display(); student s; teacher t; int c,ch; do{ system("cls"); cout<<"ntttMain Menu n" ; cout<<"nttEnter choice whose data to be maintainedn"; cout<<"ntt1. Studentn"; cout<<"ntt2. Teachern"; cout<<"ntt3. Exitn"; cin>>c; cout<<"n"; switch(c) {case 1:s.menu(); break;
  • 13. case 2:t.menu(); break; case 3:cout<<"nHave a Nice Day :)n"; getch(); exit(0); } }while(1); getch(); }