Você está na página 1de 20

COMPUTER SCIENCE

PROJECT FILE
ON

CRICKET RECORD

PROJECT BY:
HIMANSHU MATHPAL

XII-A

SESSION: 2018-2019

UNIVERSAL PUBLIC SCHOOL


TABLE OF CONTENTS

Certificate

Acknowledgement

Header files and their purpose

Coding

Limitations

Requirements

Bibliography
Acknowledgement
I thank my Computer Science teacher
Mrs. Renu Manglik for guidance and
support. I also thank my Principal Mrs.
Monita Gopal. I would also like to
thank my parents and my sister for
encouraging me during the course of
this project. Finally I would like to
thank CBSE for giving me this
opportunity to undertake this project.
Certificate
This is to certify that Himanshu Mathpal of class 12th,
Universal Public School, Delhi has successfully
completed his project in computer science practical
for the AISSCE as prescribed by CBSE in the year 2018-
2019.

Date:

Registration No.:

Signature of Internal Signature of External


Examiner Examiner

__________________ __________________
REQUIREMENTS

HARDWARE REQUIRED
 Printer, to print the required documents of the project
 Compact Drive
 Processor : Pentium III
 Ram : 64 MB
 Hard disk : 20 GB

SOFTWARE REQUIRED
 Operating system : Windows XP
 Turbo C++, for execution of program and
 Ms word, for presentation of output.
HEADER FILES USED AND
THEIR PURPOSE

1. FSTREAM.H – for file handling, cin and cout


2. CONIO.H – for clrscr() and getch() functions
3. STDIO.H – for standard I/O operations
4. STRING.H – for string handling
5. CTYPE.H – for character handling
CODING
#include<fstream.h>
#include<conio.h>
#include<ctype.h>
#include<stdio.h>
#include<string.h>

class data
{
char name[30];
int playercode;
int M1R;
int M2R;
int M3R;
int total_run;
public:
data()
{
playercode=0;
strcpy(name,"");
M1R=0;
M2R=0;
M3R=0;
total_run=0;
}

void enter_name_runs() //TO TAKE ENTRY OF NEW RECORDS


{

cout<<"\nENTER PLAYER CODE (INTEGER):";


cin>>playercode;
cout<<"\nENTER PLAYER NAME:";
gets(name);
cout<<"\nFIRST MATCH RUN(S):";
cin>>M1R;
cout<<"\nSECOND MATCH RUN(S):";
cin>>M2R;
cout<<"\nTHIRD MATCH RUN(s):";
cin>>M3R;
total_runs();
}
void show_record() //TO DISPLAY THE RECORDS EXISTING IN THE FILE
{

cout<<"PLAYER CODE:"<<playercode<<endl;
cout<<"PLAYER NAME: "<<name<<endl;
cout<<"FIRST MATCH RUN(S): "<<M1R<<endl;
cout<<"SECOND MATCH RUN(S): "<<M2R<<endl;
cout<<"THIRD MATCH RUN(S): "<<M3R<<endl;
cout<<"TOTAL RUN(S): "<<total_run<<endl;
}
void total_runs() //CALCULATE TOTAL RUNS
{
total_run=M1R+M2R+M3R;
}
int getplayercode()
{
return playercode;
}
int gettotalruns()
{
return total_run;
}
char* get_name()
{
return name;
}

void modify_data() //TAKE DATA TO MODIFIFY EXISTING RECORD


{
cout<<"\nENTER NEW DATA FOR MODIFCATION:::::::: ";
cout<<"\nENTER FIRST MATCH RUN(S) : ";
cin>>M1R;
cout<<"\nENTER SECOND MATCH RUN(S) : ";
cin>>M2R;
cout<<"\nENTER THIRD MATCH RUN(s) : ";
cin>>M3R;
total_runs();
}
};
data d;
fstream file;
fstream file1;
//* * * * * * * * * * CALCULATE HIGHEST RUN(s) * * * * * * * * * * * * *
void highest()
{
file.open("RECORD.DAT",ios::in|ios::binary);
int post=0,tr=0,plr_code=0,run=0;

file.read((char*)&d,sizeof(d));
while(file)
{
run=d.gettotalruns();
if(run>tr)
{
post=file.tellg();
tr=run;
}
file.read((char*)&d,sizeof(d));
}file.close();
file.open("RECORD.DAT",ios::in|ios::binary);
file.seekg(post-sizeof(d));
file.read((char*)&d,sizeof(d));
cout<<"\n::::::::::HIGHEST RUN GETTER DATA::::::::::";
cout<<"\nHIGHEST RUN(S) GETTER CODE : "<<d.getplayercode();
cout<<"\nHIGHEST RUN(S) GETTER PLAYER IS : "<<d.get_name();
cout<<"\nPLAYER TOTAL RUN(S) ARE : "<<tr;
float avg;
avg=(tr)/3;
cout<<"\nPLAYER AVERAGE IS : "<<avg;
file.close();
}
//* * * * * * * * * * * * INSERT NEW RECORD(s) * * * * * * * * * * * * *
void insert()
{
int i,no;
file.open("RECORD.DAT",ios::in|ios::app|ios::binary);
cout<<"\n ::ENTRY OF NEW RECORD(S):: ";
cout<<"\nHOW MANY RECORD DO YOU WANT TO ENTER: ";
cin>>no;
for(i=1;i<=no;i++)
{
d.enter_name_runs(); //insert records
file.write((char*)&d,sizeof(d));
}file.close();
}
//* * * * * * * * * * * * * DISPLAY EXISTING RECORD(s) * * * * * * * * * *
void display()
{
file.open("RECORD.DAT",ios::in|ios::binary);
cout<<"|||||||||||||||||||||| ENTERED RECORD(S) ||||||||||||||||||||||||"<<endl;
file.read((char*)&d,sizeof(d));
while(file)
{
d.show_record();
file.read((char*)&d,sizeof(d));
}file.close();
}
//* * * * * * * * * * * * * SEARCH RECORD * * * * * * * * * * * * * * * *
void search()
{
int p,r,f=0;
file.open("RECORD.DAT",ios::in|ios::binary);
cout<<"\nENTER PLAYER CODE TO SEE HIS RECORD: ";
cin>>r;
file.seekg(0);
file.read((char*)&d,sizeof(d));
while(file)
{
p=d.getplayercode();
if(r==p)
{
d.show_record();
f=1;
break;
}
else
{
file.read((char*)&d,sizeof(d));
}
}file.close();
if(f==0)
{
cout<<"\nTHERE IS NO RECORD WHICH HAVE THIS PLAYER CODE";
}
}
//* * * * * * * * * * * * * * MODIFY DATA * * * * * * * * * * * * * * * * * *
void modify()
{
int posi=0,got=0,dmd=0;
cout<<"\nENTER THE PLAYER CODE WHOSE RECORD IS TO BE MODIFIED: ";
cin>>dmd;
int ifdata=1;
file.open("RECORD.DAT",ios::in|ios::out|ios::binary);
posi=file.tellg();
while(file)
{
file.read((char*)&d,sizeof(d));
got=d.getplayercode();
if(dmd==got)
{
file.seekg(posi);
d.modify_data();
ifdata=2;
file.write((char*)&d,sizeof(d));
break;
}
posi=file.tellg();
}
file.close();
if(ifdata==1)
{
cout<<" DATA IS NOT AVAILABLE FOR MODIFICATION "<<endl;
}
}
//* * * * * * * * * * * * DELETE RECORD* * * * * * * * * * * * * * * * * *
void delete_record()
{
int pointer=0,remove_record=0,size=0,code_get=0;
// size=sizeof(file);
cout<<"\n ENTER PLAYER CODE WHOSE RECORD IS TO BE DELETED: ";
cin>>remove_record;
file.open("RECORD.DAT",ios::in|ios::out|ios::binary);
file1.open("TEMPO.DAT",ios::in|ios::out|ios::binary);
file.seekg(0);
while(file)
{
file.read((char*)&d,sizeof(d));
code_get=d.getplayercode();
if(remove_record==code_get)
{
cout<<" ";
}
else
{
file1.write((char*)&d,sizeof(d));
}
}
file.close();
file1.close();
remove("RECORD.DAT");
rename("TEMPO.DAT","RECORD.DAT");
}
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
void main()
{
clrscr();
int choice;
do
{
clrscr();
cout<<"=*=*=*=*=* PLAYER RECORD KEEPING SYSTEM *=*=*=*=*"<<endl;
cout<<"1.INSERT RECORD"<<endl;
cout<<"2.DISPLAY RCEORD"<<endl;
cout<<"3.SEARCH RECORD"<<endl;
cout<<"4.MODIFY RECORD"<<endl;
cout<<"5.HIGHEST RUNS "<<endl;
cout<<"6.DELETE PREVIOUS ENTERED RECORD"<<endl;
cout<<"7.EXIT "<<endl;
cout<<"ENTER YOUR CHOICE: ";
cin>>choice;
clrscr();
switch(choice)
{
case 1: insert();
getch();
break;
case 2: display();
getch();
break;
case 3: search();
getch();
break;
case 4: modify();
getch() ;
break;
case 5: highest();
getch();
break;
case 6: delete_record();
cout<<"ENTERED RECORD IS DELETED";
getch();
break;
case 7: cout<<"EXITING....";
getch();
break;
default: cout<<"WRONG CHOICE";
break;
}
}
while(choice!=7);
getch();
}
Screen shots
MAIN MENUE:
Display :

Search :
Modify :

Display modified data :


Highest run scored :

Delete :
Diplay after deletion :

Exiting:
Bibliography
 SUMITA ARORA
CLASS NOTES
 GOOGLE
LAST YEAR PROJECT FILE

Você também pode gostar