You are on page 1of 18

INTRODUCTION

This project is about student record system of an educational institution. This project is mainly used to maintain the records of students performance in their board examinations. This program not only helps to maintain the record of the students, it also helps to display the report card of the students by just entering the registration number. Furthermore, this program enables to view the overall records of all pass as well as fail students according to their desire. This project has great uses in schools and colleges as it helps to retrieve the desired information quickly and easily. This program is a menu based program which performs various operations as instructed by the user. There are five options in this program:

OPTION 1:
By selecting this option, users can enter various information regarding a student such as students name, registration number, and internal and external marks obtained by the student in five subjects. This entered information is automatically recorded in file reportcard.dat. This information can be retrieved by the user in the form of report card by choosing option 2.

OPTION 2:
Users can view the report card of desired student by choosing this option. Once the data of students are entered by the user, it is recorded in the file reportcard.dat which can be retrieved any time. When the user selects option 2, he/she should enter the registration number of the student whose report card he/she wants to view. As soon as the registration number is entered, the desired report card is displayed.

OPTION 3:
The third option instructs the computer to display the records of the students who have passed the examination. If we choose this option, we receive the name, registration number, percentage and division of the passed students only. When we choose this option, all the data stored in the file is read and only the data of passed students is returned.

OPTION 4:
On choosing the fourth option, we can view the records of the students who have failed the examination. If we chose this option, all the data stored in the file is read and only the data of failed students is returned and thus, the name, registration number and percentage obtained by failed student is displayed.

OPTION 5:
The fifth option terminates the program i.e., it allows us to exit from the program.

The class diagram of this program is given below:

CLASS: student DATA: Name Registration number Internal Marks External marks Total Grand total Percentage Subject name Division Result

FUNCTIONS: getdata() getint() getext() writetofile() readfromfile() showdata() caltot() showpass() showfail()

PROGRAM CODE:
3

//report card #include<iostream> #include<cstdlib> #include<cstring> #include<fstream> #include<iomanip> using namespace std; class student { private: char name[25]; int regno; char sub[5][35]; char div[10], result[10]; int intm[5],extm[5],tot[5],gtot; float per; public: student() { strcpy(sub[0],"BUSINESS COMMUNICATION"); strcpy(sub[1],"BUSINESS FINANCE"); strcpy(sub[2],"FINANCIAL ACCOUNTING"); strcpy(sub[3],"OPERATIONS MANAGEMENT"); strcpy(sub[4],"COMPUTER PROGRAMMING II"); }

void getdata(); void getint(); void getext(); void writetofile(); void readfromfile(); void showdata(); void caltot(); void showpass(); void showfail(); };

void student::getdata() { cout<<"\nEnter data on student: "; cout<<"\nEnter name: "; cin>>name; cout<<"\nEnter Registration no.: "; cin>>regno;

} void student::getint() { cout<<"\nEnter internal marks(out of 40):\n"; for(int i=0;i<5;i++)

{ cout<<sub[i]<<":"; cin>>intm[i]; } } void student::getext() { cout<<"\nEnter external marks(out of 60):\n "; for(int i=0;i<5;i++) { cout<<sub[i]<<": "; cin>>extm[i]; } } void student::showdata() { cout<<"\n**********STUDENT REPORT CARD***********"<<endl; cout<<"\t~~~~~~~ BBA THIRD SEMESTER ~~~~~~~~"<<endl; cout<<"NAME: "<<name<<endl; cout<<"REGISTRATION NO.: "<<regno<<endl; cout<<"-------------------------------------------------------------------------------------"<<endl; cout<<setw(5)<<"S.No."<<setw(30)<<"SUBJECT"<<setw(14)<<"INT. MARKS"<<setw(14)<<"EXT. MARKS"<<setw(17)<<"MARKS OBTAINED"; cout<<"-------------------------------------------------------------------------------------"<<endl;
6

for(int i=0;i<5;i++) cout<<setw(5)<<i+1<<setw(30)<<sub[i]<<setw(14)<<intm[i]<<setw(14 )<<extm[i]<<setw(17)<<tot[i]<<endl;

cout<<setw(60)<<"TOTAL MARKS"<<"\t"<<gtot<<endl; cout<<setw(60)<<"PERCENTAGE"<<"\t"<<per<<endl; cout<<setw(60)<<"RESULT\t"<<result<<endl; if(strcmp(result,"PASS")==0) cout<<setw(60)<<"DIVISION\t"<<div<<endl;

} void student:: caltot() { for(int i=0;i<5;i++) { tot[i]=intm[i]+extm[i]; } gtot=0; for(int i=0;i<5;i++) { gtot+=tot[i]; } per=static_cast<float>(gtot)/500*100; int flag=1; for(int i=0;i<5;i++)
7

{ if(intm[i]<18||extm[i]<27) { flag=0;

break; } } if(flag) { strcpy(result,"PASS"); if(per>=80) { strcpy(div,"DIST.");

} else if(per>=60) { strcpy(div,"FIRST");

} else if(per>=50) { strcpy(div,"SECOND");

} else { strcpy(div,"THIRD");

} else { strcpy(result,"FAIL"); } } void student::showpass() { cout<< "\n***********RECORD OF PASSED STUDENTS*****************"<<endl; cout<<"----------------------------------------------------------------"<<endl; cout<<setw(8)<<"\nREGD NO."<<setw(20)<<"NAME"<<setw(11)<<"PERCENTAGE"<<setw(10)<<"DIVIS ION"<<endl; cout<<"----------------------------------------------------------------"<<endl; ifstream infile("reportcard.dat",ios::binary); while(!infile.eof()) {

if(infile.read(reinterpret_cast<char*>(this),sizeof(*this))>0); if(strcmp(result,"PASS")==0) { cout<<setw(8)<<regno<<setw(20)<<name<<setw(11)<<per<<setw(10)<<d iv<<endl; }

} } void student::showfail() { cout<< "\n***********RECORD OF FAILED STUDENTS*****************"<<endl; cout<<"----------------------------------------------------------------"<<endl; cout<<setw(8)<<"\nREGD NO."<<setw(20)<<"NAME"<<setw(11)<<"PERCENTAGE"<<endl; cout<<"----------------------------------------------------------------"<<endl; ifstream infile("reportcard.dat",ios::binary); while(!infile.eof()) { if(infile.read(reinterpret_cast<char*>(this),sizeof(*this))>0); if(strcmp(result,"FAIL")==0) {

10

cout<<setw(8)<<regno<<setw(20)<<name<<setw(11)<<per<<endl; }

} } void student::writetofile() { ofstream outfile("reportcard.dat",ios::binary|ios::app); getdata(); getint(); getext(); caltot(); outfile.write(reinterpret_cast <char*>(this),sizeof(*this)); } void student::readfromfile() { ifstream infile("reportcard.dat",ios::binary); int n; cout<<"Enter reg no.: "; cin>>n; while(!infile.eof()) { infile.read(reinterpret_cast <char*>(this),sizeof(*this));

11

if(regno==n) { showdata(); break; }

} } int main() { student s; int choice; while(1) { cout<<"\n\n************STUDENT RECORD SYSTEM************"<<endl; cout<<"Choose one option"<<endl; cout<<"1-> ENTER RECORD OF STUDENT"<<endl; cout<<"2-> SHOW REPORT CARD OF DESIRED STUDENT"<<endl; cout<<"3-> SHOW INFORMATION OF PASSED STUDENTS"<<endl; cout<<"4-> SHOW INFORMATION OF FAILED STUDENTS"<<endl; cout<<"5-> EXIT FROM THE PROGRAM"<<endl; cout<<"\tEnter your choice: "; cin>>choice;
12

switch(choice) { case 1: s.writetofile(); break; case 2: s.readfromfile(); break; case 3: s.showpass(); break; case 4: s.showfail(); break; case 5: exit(0); } } system("pause"); return 0; }

OUTPUT:
13

14

15

16

17

CONCLUSION:
This is an object oriented program. In this program header <iostream>, <cstdlib>, <fstream>, <cstring>, and <iomanip> are used. In order to use library function in the program we must include its header. For input and output function, we use header <iostream>. To use different string manipulating functions, we use header <cstring>. To use setw() manipulator to display the number or string within the field specified in argument, we use header <iomanip>. For file processing using file stream we should include the header <fstream>. We can make a class with different data and function and create its objects. The member function of class is called with the object of class. To retrieve information for future reference we write the records or information in file and the information that is written in the file can be read or accessed at the time of need. The information that is not recorded in file gets erased and user will not be able store data and hence would not be able to access data in future. We can have ASCII and binary files. However, the binary format is the most efficient way of storing data in files. Most of the commercial applications use binary file format to store data. Hence, this program can be useful in schools and colleges to store the data of students in file, to retrieve the required data as well as to prepare and display the report card of students.

18

You might also like