Вы находитесь на странице: 1из 23

DEPARTMENT OF COMPUTER SCIENCE

ST.XAVIER’S HIGH SCHOOL


KHANDAGIRI,BHUBANESWAR

CERTIFICATE
This is to certify that the Computer Science Investigatory
Project entitled “Student Management System” submitted
to Department of Computer Science, St.Xavier’s High
School,Khandagiri,Bhubaneswar
has been successfully completed by Soumya Suman
Padhiary of Class XII-A in partial fulfilment of curriculum
of Central Board of Secondary Education(CBSE) leading to
the award of Annual Examination of the academic year
2019-20.

Signature of Signature of Signature of

Internal Tecaher Vice – Principal External


DECLARATION
I hereby declare that the Computer Science Investigatory

Project entitled “Student Management System” submitted

to the Department of Computer Science,St.Xavier’s High

School,Khandagiri,Bhubaneswar has been prepared me.

All the codings were done by me personally.

Student Signature
ACKNOWLEDGEMENT

I feel proud to present my Computer Science Investigatory


Project on the topic “Student Management System”.This
project would not have been feasible without the proper
and rigorous guidance of my Computer Science teacher
who guided me throughout this project in every possible
way.A project involves a lot of hardwork and dedication
which has to be carried out by the student throughout to
produce a successful project.I hope this project will prove
to be a breeding ground for next generation of student and
will guide them in every possible way.

Student Signature
INDEX
SL NO. TOPIC PAGE NO.
1 Header Files Used
2 Files Generated
3 Working description
4 Code
5 Output Screen
6 Bibliography
HEADER FILES USED
1. iostream.h – For cin and cout
2. fstream.h – For file handling
3. stdio.h – For standard input/output operations
4. string.h – For string handling
5. stdlib.h – For functions contained in standard library
FILES GENERATED
DATA FILES
stu.dat
temp.dat

PROGRAM FILE
studentmanagementsystem.cpp

OBJECT FILE
studentmanagementsystem.obj

EXECUTION FILE
studentmanagementsystem.cpp
WORKING DESCRIPTION
The project is “STUDENT MANAGEMENT SYSTEM”.
In this project we can do the following things:-
 Add records
 Search and display a record
 Insert a record
 Modify a record
 Delete a record

The project contains different header files, built-in


function, user defined function, class, if-else-if and loop.
CODE
#include<iostream> ……………………………………………………………..//HEADER FILES

#include<fstream>

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

using namespace std;

class student ……………………………………………………………………….//CLASS USED IN PROGRAM

int roll;

char name[25];

int Class;

float marks;

char grade;

char father[25];

char mother[25];

char area[25];

char city[30];

int PIN;

public:

void getdata()

cout<<"Roll no: ";

cin>>roll;

cout<<"Class:(in number) ";

cin>>Class;

cout<<"Name: ";
cin>>name;

cout<<"Total Marks: ";

cin>>marks;

if(marks>=75)

grade='a';

else if(marks>=60)

grade='b';

else if(marks>=50)

grade='c';

else if(marks>=40)

grade='d';

else grade='f';

cout<<"Father's Name: ";

cin>>father;

cout<<"Mother's Name: ";

cin>>mother;

cout<<"enter the area " ;

cin>>area;

cout<<"enter the city " ;

cin>>city;

cout<<"enter PIN code " ;

cin>>PIN;

void putdata()
{

cout<<"Roll no. "<<roll<<"\tName: "<<name<<"\tClass: "<<Class;

cout<<"\nMarks: "<<marks<<"\ngrade: "<<grade<<"\nFather's Name:


"<<father<<"\tMother's Name: "<<mother;

cout<<"Area: ";

cout<<area<<endl;

cout<<"City: "<<city<<endl;

cout<<"PIN Code: "<<PIN;

cout<<endl<<endl;

int getrno()

return roll;

void modify();

};

void student::modify()

cout<<"Rollno :"<<roll<<endl;

cout<<"Name:" << name <<"\t Class :" <<Class

<<"\t Marks : " << marks << endl;

cout<<"Enter new details. "<< endl;

char nm[20]=" ";

int Cl;

float mks;

char fther[25];
char mther[25];

char areaa[25];

char cty[30];

int PN;

cout << "New Name :(Enter '.' to retain old one)";

cin >>nm;

cout << "New Class :(press '-1' to retain old one)";

cin >>Cl;

cout << "New Marks :(press '-1' to retain old one)";

cin>>mks;

cout << "New Father Name :(Enter '.' to retain old one)";

cin >>fther;

cout << "New Mother Name :(Enter '.' to retain old one)";

cin >>mther;

cout << "New Area :(Enter '.' to retain old one)";

cin >>areaa;

cout << "New city :(Enter '.' to retain old one)";

cin >>cty;

cout << "New PIN :(Enter -1 to retain old one)";

cin >>PN;

if(strcmp(nm,".")!=0)

strcpy(name,nm);

if(strcmp(fther,".")!=0)

strcpy(father,fther);

if(strcmp(mther,".")!=0)

strcpy(mother,mther);

if(strcmp(areaa,".")!=0)

strcpy(area,areaa);
if(strcmp(cty,".")!=0)

strcpy(city,cty);

if(Cl!=-1)

Class=Cl;

if(PN!=-1)

PIN=PN;

if(mks!=-1)

{marks=mks;

if(marks>= 75) grade='A';

else if(marks>=60) grade = 'B';

else if(marks>= 50) grade = 'C';

else if(marks>= 40) grade='D';

else grade='F';

int main()

{ int choice,n;

for(int k=0;;k++)

cout<<" STUDENT MANAGEMENT SYSTEM \n";

cout<<"1.ADD RECORDS TO THE FILE\n";

cout<<"2.SEARCH AND DISPLAY A RECORD \n";

cout<<"3.INSERT A RECORD \n";

cout<<"4.MODIFY A RECORD \n";

cout<<"5.DELETE A RECORD \n";

cout<<"6.EXIT\n";
cout<<"WHAT DO YOU WANT TO DO??(add records if not added)";

cin>>choice;

if(choice==1)……………………………………………………………………………………//ADDING THE RECORDS

cout<<"Enter the number of students in file";

cin>>n;

student s[n];

ofstream ofs;

ofs.open("stu.dat",ios::out|ios::binary);

for(int i=0;i<n;i++)

s[i].getdata();

ofs.write((char*)&s[i],sizeof(s[i]));

cout<<endl;

ofs.close();

ifstream ifs;

ifs.open("stu.dat",ios::in|ios::binary);

ifs.seekg(0);

for(int i=0;i<n;i++)

ifs.read((char*)&s[i],sizeof(s[i]));

s[i].putdata();
}

ifs.close();

if (choice==2)……………………………………………………//SEARCHING AND DISPLAYING A RECORD

student st;

int rn;

char found='n';

ifstream fi("stu.dat",ios::in);

cout<<"Enter rollno to be searched for:";

cin>>rn;

while(!fi.eof())

fi.read((char*)&st,sizeof(st));

if(st.getrno()==rn)

st.putdata();

found='y';

break;

if(found=='n')

cout<<"Rollno not found in file!!"<<endl;

fi.close();

if(choice==3)…………………………………………………………………………//INSERTING A NEW RECORD

student s1,stud;

ifstream fi("stu.dat",ios::in|ios::binary);
ofstream fo("temp.dat",ios::out|ios::binary);

char last='y';

cout<<"enter the details of student whose record is to be inserted";

s1.getdata();

while(!fi.eof())

fi.read((char*)&stud,sizeof(stud));

if(s1.getrno()<=stud.getrno())

fo.write((char*)&s1,sizeof(s1));

last='n';

break;

else

fo.write((char*)&stud,sizeof(stud));

if(last=='y')

fo.write((char*)&s1,sizeof(s1));

else if(!fi.eof())

while(!fi.eof())

{fi.read((char*)&stud,sizeof(stud));

fo.write((char*)&stud,sizeof(stud));

}
fi.close();

fo.close();

remove("stu.dat");

rename("temp.dat","stu.dat");

fi.open("stu.dat",ios::in);

cout<<"file now contains\n";

while(!fi.eof())

fi.read((char*)&stud,sizeof(stud));

if(fi.eof())

break;

stud.putdata();

fi.close();

if(choice==4) ………………………………………………………………………………//MODIFYING A RECORD

{student s3,stud2;

fstream fio("stu.dat",ios::in|ios::out|ios::binary);

int rno; long pos; char found='f';

cout <<"Enter roll no of student whose record is to be modified \n ";

cin >>rno;

while(!fio.eof())

pos=fio.tellg();

fio.read((char*)&s3,sizeof(s3));

if(s3.getrno()==rno)

{s3.modify();
fio.seekg(pos);

fio.write((char*)&s3,sizeof(s3));

found='t';

break;

if(found=='f')

cout << " Record not found!! \n";

fio.seekg(0);

cout << "Now the file contains \n ";

while(!fio.eof())

fio.read((char*)&stud2,sizeof(stud2));

if(fio.eof())break;

stud2.putdata();

fio.close();

if(choice==5) …………………………………………………………………………………//DELETING A RECORD

student s2,stud1;

ifstream fio("stu.dat",ios::in|ios::binary);

ofstream file("temp.dat ", ios::out|ios::binary);

int rno;

char found ='f',confirm='n';

cout << "Enter rollno of student whose record is to be deleted \n ";

cin >>rno;
while(!fio.eof())

{fio.read((char*)&s2,sizeof(s2));

if(s2.getrno()==rno)

{s2.putdata();

found='t';

cout<<"Are you sure you want to delete this record?(y/n)..";

cin>>confirm;

if(confirm=='n')

file.write((char*)&s2, sizeof(s2));

else

file.write((char*)&s2,sizeof(s2));

if(found=='f')

cout<<"Record not found!!\n";

fio.close();

file.close();

remove("stu.dat");

rename("temp.dat","stu.dat");

fio.open("stu.dat",ios::in);

cout << "Now the file contains\n";

fio.seekg(0);

while(!fio.eof())

fio.read((char*)&stud1,sizeof(stud1));

if(fio.eof()) break;

stud1.putdata();
}

fio.close();

if(choice==6)

exit(0);

return 0;

}
OUTPUT
 Adding records to the file

 Searching and displaying records

 Inserting a record


 Inserting a record

 Modifying a record
 Deleting a record
BIBLIOGRAPHY
 Computer Science with C++ by Sumita Arora
 en.wikipedia.com
 google.com

Вам также может понравиться