VIKRANT2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 47

Acknowledgement

I am very much thankful to my respected


teachers under whose kind guidance I’ve made
this project.
Also I would like to thank my friends who gave
me creative ideas to make this project.
PROJECT

STUDENT REPORT
CARD

Developed sincerely by :-

Vikrant
Index

1. Aim
2. Header files used
3. Program code
4. Output
5. Comments by teacher
1. Aim

The main aim of this project is to provide the facility


to insert results, to watch out the results of a class,
result of a particular student and also to
amendments in the existing result if necessary.
2. Header files used

(i) iostream.h
(ii) fstream.h
(iii) conio.h
(iv) stdio.h
(v) iomanip.h
3. Program Code
/*----------------------------------------------------------*\
:| HEADER FILES USED IN PROJECT |:
\*----------------------------------------------------------*/

#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
#include<stdio.h>
#include<conio.h>

/*----------------------------------------------------------*\
:| CLASS USED IN PROJECT |:
\*----------------------------------------------------------*/

class student
{
int rollno;
char name[50];
int p_marks, c_marks, m_marks, e_marks, cs_marks;
float per;
char grade;
void calculate(); //function to calculate grade

public:

void getdata(); //function to accept data from user


void showdata(); //function to show data on screen
void show_tabular(); //function to show result in tabular form
int retrollno(); //function to return roll no. of student
}; //class ends here

void student::calculate()
{
per=(p_marks+c_marks+m_marks+e_marks+cs_marks)/5.0;
if(per>=60)
grade='A';

else
if(per>=50)
grade='B';

else
if(per>=33)
grade='C';

else
grade='F';
}

void student::getdata()
{
cout<<"\t\t #***************** ENTRY MENU ****************# ";
cout<<"\n\t\t .............................................";
cout<<"\n\t\t ";
cout<<"\n\t\t ENTER STUDENT NAME : ";
gets(name);

cout<<"\n\t\t ENTER THE ROLL NO. OF STUDENT : ";


cin>>rollno;

cout<<"\n\t\t ENTER MARKS IN PHYSICS : ";


cin>>p_marks;

cout<<"\n\t\t ENTER MARKS IN CHEMISTRY : ";


cin>>c_marks;

cout<<"\n\t\t ENTER MARKS IN MATHEMATICS : ";


cin>>m_marks;

cout<<"\n\t\t ENTER MARKS IN COMPUTER SCI. : ";


cin>>cs_marks;

cout<<"\n\t\t ENTER MARKS IN ENGLISH : ";


cin>>e_marks;

cout<<"\n\t\t STUDENT RECORD HAS BEEN CREATED SUCCESSFULLY ";


cout<<"\n\t\t .............................................. ";
cout<<"\n\t\t #*********************************************# \n\t\t ";

calculate();
}

void student::showdata()
{
cout<<"\t\t #***************** ENTRY MENU ****************# ";
cout<<"\n\t\t .............................................";
cout<<"\n\t\t ";
cout<<"\n\t\t STUDENT NAME : "<<name;
cout<<"\n\t\t ";
cout<<"\n\t\t ROLL NO. OF STUDENT : "<<rollno;
cout<<"\n\t\t ";
cout<<"\n\t\t MARKS IN PHYSICS : "<<p_marks;
cout<<"\n\t\t ";
cout<<"\n\t\t MARKS IN CHEMISTRY : " <<c_marks;
cout<<"\n\t\t ";
cout<<"\n\t\t MARKS IN MATHEMATICS : "<<m_marks;
cout<<"\n\t\t ";
cout<<"\n\t\t MARKS IN COMPUTER SCIENCE: "<<cs_marks;
cout<<"\n\t\t ";
cout<<"\n\t\t MARKS IN ENGLISH : "<<e_marks;
cout<<"\n\t\t ";
cout<<"\n\t\t PERCENTAGE : "<<per;
cout<<"\n\t\t GRADE : "<<grade;
cout<<"\n\t\t ............................................. ";
cout<<"\n\t\t #*********************************************# \n\t\t ";

}
void student::show_tabular()
{

cout<<setw(3)<<rollno<<setw(13)<<name<<setw(9)<<p_marks<<setw(9)<<c_marks
<<setw(9)<<m_marks<<setw(9)
<<e_marks<<setw(7)<<cs_marks<<setw(9)<<per<<" % "<<"
"<<grade<<endl;
}

int student::retrollno()
{
return rollno ;
}

/*----------------------------------------------------------*\
:| FUNCTION DECLARATION |:
\*----------------------------------------------------------*/

void write_student(); //function to write the record in binary file

void display_all(); //function to read all records from binary file


void display_sp(int); //function to accept rollno and read record from binary

void modify_student(int); //function to accept rollno and update record of binary file

void delete_student(int); //function to accept rollno and delete selected records


//from binary files

void class_result(); //function to display all records in tabular format from


//binary files

void result(); //function to display result menu

void intro(); //function to display welcome screen

void entry_menu(); //function to display entry menu on screen

/*----------------------------------------------------------*\
:| THE MAIN FUNCTION OF PROGRAM |:
\*----------------------------------------------------------*/

int main()
{
char ch;

cout.setf(ios::fixed|ios::showpoint);
cout<<setprecision(2); // program outputs decimal number to two decimal places

clrscr();

intro();

do
{
clrscr();

cout<<"\t\t #***************** MAIN MENU ****************# ";


cout<<"\n\t\t .............................................";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 1. RESULT MENU l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 2. ENTRY / EDIT MENU l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 3. EXIT l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t l";
cout<<"\n\t\t l.............................................l";
cout<<"\n\t\t #*********************************************# \n\n\n\t\t ";
cout<<">>>>>>>>>>> PLEASE ENTER YOUR CHOICE <<<<<<<<<<";
cout<<"\n\t\t\t ";
cin>> ch;

clrscr();

switch(ch)
{
case '1': result();
break;

case '2': entry_menu();


break;

case '3':
break;

default :cout<<"\a";

}while(ch!='3');

return 0;
}

/*-----------------------------------------------------------*\
: | FUNCTION TO WRITE STUDENT DETAILS | :
\*-----------------------------------------------------------*/

void write_student()
{
student st;
ofstream outFile;
outFile.open("student.dat",ios::binary|ios::app);

st.getdata();

outFile.write((char *) &st, sizeof(student));


outFile.close();

cin.ignore();
getch();
}

/*-------------------------------------------------------------------------*\
: | FUNCTION TO READ SPECIFIC RECORD FROM FILE | :
\*-------------------------------------------------------------------------*/

void display_sp(int n)
{
student st;

ifstream inFile;
inFile.open("student.dat",ios::binary);

if(!inFile)
{ cout<<"\n\n\n\n\t\t ==============================================";
cout<<"\n\t\t # FILE CAN'T BE OPENED PRESS ANY KEY... #";
cout<<"\n\t\t ==============================================\n\t\t\t";

getch();
return;

int flag=0;

while(inFile.read((char *) &st, sizeof(student)))


{
if(st.retrollno()==n)
{
st.showdata();
flag=1;
}
}
inFile.close();

if(flag==0)
{
cout<<"\n\n\n\n\t\t ==============================================";
cout<<"\n\t\t # RECORD NOT FOUND #";
cout<<"\n\t\t
==============================================\n\t\t\t";

}
getch();

/*----------------------------------------------------------*\
:| FUNCTION TO MODIFY RECORD |:
\*----------------------------------------------------------*/

void modify_student(int n)
{
int found=0;
student st;

fstream File;
File.open("student.dat",ios::binary|ios::in|ios::out);

if(!File)
{
cout<<"\n\n\n\n\t\t ==============================================";
cout<<"\n\t\t # FILE CAN'T BE OPENED PRESS ANY KEY... #";
cout<<"\n\t\t ==============================================\n\t\t\t";

getch();
return;
}

while(File.read((char *) &st, sizeof(student)) && found==0)


{
if(st.retrollno()==n)
{
st.showdata();
getch();
clrscr();

cout<<"\n\t\t ==============================================";
cout<<"\n\t\t # PLEASE ENTER NEW DETAILS OF STUDENT #";
cout<<"\n\t\t ==============================================\n";

st.getdata();

int pos=(-1)*sizeof(st);

File.seekp(pos,ios::cur);
File.write((char *) &st, sizeof(student));

cout<<"\n\t\t ==============================================";
cout<<"\n\t\t # RECORD UPDATED #";
cout<<"\n\t\t ==============================================\n";

found=1;
}

File.close();

if(found==0)
{ cout<<"\n\n\n\n\t\t ==============================================";
cout<<"\n\t\t # RECORD NOT FOUND #";
cout<<"\n\t\t
==============================================\n\t\t\t";
}

getch();

/*-------------------------------------------------------------------------*\
:| FUNCTION TO DELETE A RECORD FROM A FILE |:
\*-------------------------------------------------------------------------*/

void delete_student(int n)
{
student st;
char found='f', confirm='n';
ifstream inFile;
inFile.open("student.dat",ios::binary);

if(!inFile)
{
cout<<"\n\n\n\n\t\t
==============================================";
cout<<"\n\t\t # FILE CAN'T BE OPENED PRESS ANY KEY... #";
cout<<"\n\t\t
==============================================\n\t\t\t";

getch();
return;
}

ofstream outFile;
outFile.open("Temp.dat",ios::out|ios::binary);
inFile.seekg(0,ios::beg);

while(inFile.read((char *) &st, sizeof(student)))


{
if(st.retrollno()==n)
{
st.showdata();
found='t';
cout<<" Are you sure , want to delete this record? (y/n) ";
cin>>confirm ;
if (confirm=='n')
outFile.write((char *) &st, sizeof(student));
}

else
outFile.write((char *) &st, sizeof(student));
}

if(found=='f')
{
cout<<"\n\n\n\n\t\t
==============================================";
cout<<"\n\t\t # RECORD NOT FOUND #";
cout<<"\n\t\t
==============================================\n\t\t\t";
}
outFile.close();
inFile.close();

remove("student.dat");
rename("Temp.dat","student.dat");

clrscr();
class_result();

getch();
}

/*----------------------------------------------------------------------------*\
:| FUNCTION TO DISPLAY GRADE OF ALL STUDENTS |:
\*----------------------------------------------------------------------------*/

void class_result()
{
student st;

ifstream inFile;
inFile.open("student.dat",ios::binary);

if(!inFile)
{
cout<<"\n\n\n\n\t\t ==============================================";
cout<<"\n\t\t # FILE CAN'T BE OPENED PRESS ANY KEY... #";
cout<<"\n\t\t ==============================================\n\t\t\t";

getch();
return;
}

cout<<"\t\t #************ ALL STUDENT RESULT *************# ";

cout<<"\n____________________________________________________________________
____________";
cout<<"\n# R.No Name Phy. Chem. Math. Eng. CS %Age Grade
#"<<endl;
cout<<"--------------------------------------------------------------------------------\n";

while(inFile.read((char *) &st, sizeof(student)))


{
st.show_tabular();
}

getch();
inFile.close();
}

/*----------------------------------------------------------*\
:| FUNCTION TO SHOW MAIN MENU |:
\*----------------------------------------------------------*/
void result()
{
char ch;
int rno;

cout<<"\t\t #***************** MAIN MENU ****************# ";


cout<<"\n\t\t .............................................";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 1. CLASS RESULT l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 2. STUDENT RESULT CARD l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 3. BACK TO MAIN MENU l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t l";
cout<<"\n\t\t l.............................................l";
cout<<"\n\t\t #*********************************************# \n\n\n\t\t ";
cout<<">>>>>>>>>>> PLEASE ENTER YOUR CHOICE <<<<<<<<<<";
cout<<"\n\t\t\t ";
cin>>ch;

clrscr();
switch(ch)
{
case '1': class_result();
break;

case '2': cout<<"\n\n\n\n\t\t


==============================================";
cout<<"\n\t\t # Enter Roll Number Of Student #";
cout<<"\n\t\t
==============================================\n\t\t\t";
cin>>rno;

display_sp(rno);
break;

case '3': break;


default : cout<<"\a";

/*------------------------------------------------------------------*\
:| FUNCTION TO DISPLAY INTRODUCTION |:
\*------------------------------------------------------------------*/

void intro()
{
cout<<"\t\t #*********************************************# ";
cout<<"\n\t\t .............................................";
cout<<"\n\t\t l l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t\t STUDENT l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t\t REPORT CARD l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t\t PROJECT l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t MADE BY : VIKRANT l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t SCHOOL : BHEL SHIKSHA NIKETAN l\n\t\t l\t\t JHANSI \t\t
l ";
cout<<"\n\t\t l.............................................l";
cout<<"\n\t\t #*********************************************# \n\n\n\t\t ";

getch();
}

/*-------------------------------------------------------------------*\
:| FUNCTION TO DISPLAY ENTRY/EDIT MENU |:
\*-------------------------------------------------------------------*/

void entry_menu()
{
char ch;
int num;
clrscr();
cout<<"\t\t #***************** ENTRY MENU ****************# ";
cout<<"\n\t\t .............................................";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 1. CREATE STUDENT RECORD l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 2. SEARCH STUDENT RECORD l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 3. MODIFY STUDENT RECORD l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 4. DELETE STUDENT RECORD l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t 5. BACK TO MAIN MENU l";
cout<<"\n\t\t l l";
cout<<"\n\t\t l\t l";
cout<<"\n\t\t l.............................................l";
cout<<"\n\t\t #*********************************************# \n\n\n\t\t ";
cout<<">>>>>>>>>>> PLEASE ENTER YOUR CHOICE <<<<<<<<<<";
cout<<"\n\t\t\t ";
cin>>ch;

clrscr();

switch(ch)
{
case '1': write_student();
break;

case '2': cout<<"\n\n\n\n\t\t


==============================================";
cout<<"\n\t\t # Enter Roll Number Of Student #";
cout<<"\n\t\t
==============================================\n\t\t\t";
cin>>num;
display_sp(num);
break;

case '3': cout<<"\n\n\n\n\t\t


==============================================";
cout<<"\n\t\t # Enter Roll Number Of Student #";
cout<<"\n\t\t
==============================================\n\t\t\t";
cin>>num;
modify_student(num);
break;

case '4': cout<<"\n\n\n\n\t\t


==============================================";
cout<<"\n\t\t # Enter Roll Number Of Student #";
cout<<"\n\t\t
==============================================\n\t\t\t";
cin>>num;

delete_student(num);
break;

case '5': break;

default : cout<<"\a"; entry_menu();

}
}
4. Output
5. Comments by teacher

________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________

Date Signature
_______ __________

You might also like