Sei sulla pagina 1di 20

Computer

Programming
file

Name - Shashwat Singh

Class - XII –B

Roll No -
This is to certify that Shashwat singh of class XII , of St.
Columbus School ,dayal bagh ,Faridabad, has
successfully completed his project in computer practical
as prescribed by CBSE in year 2019 -2020.

Date :

Signature of internal Signature of external


examiner: examiner:
________________ _________________
I thank my computer science teacher Ms.
Sakshi vashist for the guidance and support . I
would also like to thank my parents and my
friends 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 .
## C++ Coding ##
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
#include<fstream.h>
#include<iomanip.h>
class student
{
private:
int sno,percentage,class1,admno,fees;
char sname[20],section,stream[30];
public:
void in();
void out();
void add();
void show();
void search();
void update();
void remove();
void price();
};
void student::in()
{
cout<<"enter the student number";
cin>>sno;
cout<<endl<<"enter the admno";
cin>>admno;
cout<<endl<<"enter the student name";
gets(sname);
cout<<endl<<"enter the class of the student";
cin>>class1;
cout<<endl<<"enter the section of student";
cin>>section;
cout<<endl<<"enter the fees of student";
cin>>fees;
cout<<endl<<"enter the stream of the student";
gets(stream);
cout<<endl<<"enter the percentage gain by student";
cin>>percentage;
}
void student ::out()
{
cout<<endl<<"display the student number";
cout<<sno;
cout<<endl<<"display the admno";
cout<<admno;
cout<<endl<<"display the student name";
puts(sname);
cout<<endl<<"display the class of the student";
cout<<class1;
cout<<endl<<"display the section of the student";
cout<<section;
cout<<endl<<"display the fees of the student";
cout<<fees;
cout<<endl<<"display the stream of the student";
puts(stream);
cout<<endl<<"display the percentage of the student";
cout<<percentage;
}
void student::add()
{
fstream f;
in();
f.open("student.dat",ios::out|ios::binary);
f.write((char*)&this,sizeof(student));
f.close();
}
void student::show()
{
fstream f;
f.open("student.dat",ios::in|ios::binary);
while(f.read((char*)&this,sizeof(student)))
{
out();
}
f.close();
}
void cover()
{
clrscr();
cout<<setw(53)<<"ST.COLUMBUS SCHOOL\n\n\n\n";
cout<<setw(57)<<"DAYALBAGH FBD.
HARYANA\n\n\n\n\n\n\n\n\n";
cout<<setw(60)<<"***WELCOMWE TO
STUDENT***\n\n\n\n\n\n";
cout<<setw(30)<<"MADE BY=Shashwat
Singh"<<setw(50)<<"SUBMITTED TO=Sakshi
Mam\n\n\n\n\n\n";
cout<<setw(50)<<"Press Any Key To Continue";
getch();
}
void student::search()
{
fstream f;
char sn[20];
cout<<"enter student name";
gets(sn);
f.open("student.dat",ios::binary|ios::in);
while(f.read((char*)&this,sizeof(student)))
{
if(strcmpi(sname,sn)==0)
{
cout<<"found data";
break;
}
else
{
cout<<"not found";
}
}
f.close();
}
void student::remove()
{
int a;
cout<<"enter the sno";
cin>>a;
fstream f,f1;
f.open("student.dat",ios::binary|ios::in);
f1.open("student.dat",ios::binary|ios::out);
while(f1.read((char*)&this,sizeof(student)))
{
if(sno==a)
{
continue;
}
else
{
f.write((char*)&this,sizeof(student));
}}
f.close();
f1.close();
}
void student::price()
{
if(strcmp(stream,"commerce")==0)
{
fees=3000;
}
if(strcmp(stream,"science")==0)
{
fees=3500;
}
if(strcmp(stream,"humanities")==0)
{
fees=2500;
}}
void student::update()
{
fstream f;
f.open("student.dat",ios::out|ios::in|ios::binary);
int x,p;
cout<<"enter the student no to be updated";
cin>>x;
while(f.read((char*)&this,sizeof(student)))
{
if(sno==x)
{
p=f.tellg();
f.seekp(p-sizeof(student));
cout<<"enter the new sno";
cin>>sno;
f.write((char*)&this,sizeof(student));
cout<<endl<<"student with sno"<<sno<<"has been
modifiedwith new sno"<<sno;
}
}
f.close();
}
void main()
{
cover();
char cont;
clrscr();
cout<<endl<<"\t\t\t\t$**STUDENTS**$\t\t\t";
cout<<endl<<"\n\nyour choice are";
cout<<endl<<"1.new record of student";
cout<<endl<<"2.show all record of student";
cout<<endl<<"3.search all record of student";
cout<<endl<<"4.update all record of student";
cout<<endl<<"5.delete all record of student";
cout<<endl<<"6.exit all record of student";
do
{
int choice;
student s;
cout<<endl<<"enter your choice";
cin>>choice;
switch(choice)
{
case 1:
s.add();
break;
case 2:
s.show();
break;
case 3:
s.search();
break;
case 4:
s.remove();
break;
case 5:
s.update();
break;
case 6:
cout<<endl<<"happy working with you";
getch();
}
cout<<endl<<"do you want to continue";
cin>>cont;
}
while((cont=='y')||(cont=='Y'));}
Outputs
Cover page

Add a new record


Display the details

Search the details


Update

Delete
Exit

***Thank you***

Potrebbero piacerti anche