VIKRANT2
VIKRANT2
VIKRANT2
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
(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 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);
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 modify_student(int); //function to accept rollno and update record of binary file
/*----------------------------------------------------------*\
:| 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();
clrscr();
switch(ch)
{
case '1': result();
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();
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;
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;
}
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);
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<<"\n____________________________________________________________________
____________";
cout<<"\n# R.No Name Phy. Chem. Math. Eng. CS %Age Grade
#"<<endl;
cout<<"--------------------------------------------------------------------------------\n";
getch();
inFile.close();
}
/*----------------------------------------------------------*\
:| FUNCTION TO SHOW MAIN MENU |:
\*----------------------------------------------------------*/
void result()
{
char ch;
int rno;
clrscr();
switch(ch)
{
case '1': class_result();
break;
display_sp(rno);
break;
/*------------------------------------------------------------------*\
:| 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;
delete_student(num);
break;
}
}
4. Output
5. Comments by teacher
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
________________________________
Date Signature
_______ __________