Professional Documents
Culture Documents
FILE
NAME-GAURAVNEET SINGH
CLASS-XII-E
ROLL NO-
// JEWELLERY SHOP
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
class gold
{
int gcode;
char item[20];
int weight;
int purity;
int costpg;
int polishcost;
int totcost;
public:
void getdata();
void putdata();
int getcode();
};
void gold::getdata()
{
cout<<"Enter Itemcode-";
cin>>gcode;
cout<<"Enter Item name-";
gets(item);
cout<<"Enter weight(gms) -";
cin>>weight;
cout<<"Enter purity(crt)-";
cin>>purity;
cout<<"Enter cost of gold per gram-";
cin>>costpg;
cout<<"Enter polishing cost-";
cin>>polishcost;
totcost=polishcost+weight*costpg;
}
void gold::putdata()
{
cout<<"Itemcode-"<<gcode<<"\t Item-"<<item<<"\t weight(gms)-"<<weight<<
"\t purity(crt)-"<<purity<<"\t cost/gram-"<<costpg<<"\t polish cost-"<<
polishcost<<"\t total amout-"<<totcost<<endl;
}
int gold::getcode()
{
return(gcode);
}
gold g;
class silver
{
int scode;
char item[20];
int weight;
int purity;
int costpg;
int polishcost;
int totcost;
public:
void getdata1();
void putdata1();
int getcode1();
};
void silver::getdata1()
{
cout<<"Enter Itemcode-";
cin>>scode;
cout<<"Enter Item name-";
gets(item);
cout<<"Enter weight(gms) -";
cin>>weight;
cout<<"Enter purity(crt)-";
cin>>purity;
cout<<"Enter cost of silver per gram-";
cin>>costpg;
cout<<"Enter polishing cost-";
cin>>polishcost;
totcost=polishcost+weight*costpg;
}
void silver::putdata1()
{
cout<<"Itemcode-"<<scode<<"\t Item-"<<item<<"\t weight(gms)-"<<weight<<
"\t purity(crt)-"<<purity<<"\t cost/gram-"<<costpg<<"\t polish cost-"<<
polishcost<<"\t total amout-"<<totcost<<endl;
}
int silver::getcode1()
{
return(scode);
}
silver s;
class diamond
{
int dcode;
char item[20];
int weight;
int purity;
int costpg;
int polishcost;
int totcost;
public:
void getdata2();
void putdata2();
int getcode2();
};
void diamond::getdata2()
{
cout<<"Enter Itemcode-";
cin>>dcode;
cout<<"Enter Item name-";
gets(item);
cout<<"Enter weight(gms) -";
cin>>weight;
cout<<"Enter purity(crt)-";
cin>>purity;
cout<<"Enter cost of diamond per gram-";
cin>>costpg;
cout<<"Enter polishing cost-";
cin>>polishcost;
totcost=polishcost+weight*costpg;
}
void diamond::putdata2()
{
cout<<"Itemcode-"<<dcode<<"\t Item-"<<item<<"\t weight(gms)-"<<weight<<
"\t purity(crt)-"<<purity<<"\t cost/gram-"<<costpg<<"\t polish cost-"<<
polishcost<<"\t total amout-"<<totcost<<endl;
}
int diamond::getcode2()
{
return(dcode);
}
diamond d;
class purchase
{
int idcode;
char item[20];
char sellername[20];
int pieces;
int price;
int tax;
int totcost;
public:
void getdata4();
void putdata4();
int getcode4();
};
void purchase::getdata4()
{
cout<<"Enter Seller name -";
gets(sellername);
cout<<"Enter Sellerid-";
cin>>idcode;
cout<<"Enter Item-";
gets(item);
cout<<"Enter no. of pieces-";
cin>>pieces;
cout<<"Enter price(Rs)-";
cin>>price;
cout<<"Enter Sales tax(%)-";
cin>>tax;
totcost=pieces*(price+(price*tax/100));
}
void purchase::putdata4()
{
cout<<"Seller name-"<<sellername<<"\t Sellerid-"<<idcode<<"\t Item-"<<item<<
"\t pieces-"<<pieces<<"\t price(Rs)-"<<price<<"\t Salestax(%)-"<<tax<<
"\t Net payable amount(Rs)-"<< totcost<<endl;
}
int purchase::getcode4()
{
return(idcode);
}
purchase k;
class sale
{
int icode;
char item[20];
char custname[20];
int pieces;
int price;
int tax;
int totcost;
public:
void getdata3();
void putdata3();
int getcode3();
};
void sale::getdata3()
{
cout<<"Enter customer name -";
gets(custname);
cout<<"Enter customerid-";
cin>>icode;
cout<<"Enter Item-";
gets(item);
cout<<"Enter no. of pieces-";
cin>>pieces;
cout<<"Enter price(Rs)-";
cin>>price;
cout<<"Enter Sales tax(%)-";
cin>>tax;
totcost=pieces*(price+price*tax/100);
}
void sale::putdata3()
{
cout<<"Customer name-"<<custname<<"\t Customerid-"<<icode<<"\t Item"<<item<<
void gold1()
{
int c; clrscr();
void write_file();
void read_file();
void search();
void modify();
void Delete();
do
{
cout<<" GOLD MENU"<<"\n 1.Write"<<"\n 2.Read"<<"\n 3.Search"
<<"\n 4.Modify"<<"\n 5,Delete"<<"\n 6.Exit"<< "\n Enter your choice-";
cin>>c;
if (c==1)
write_file();
if(c==2)
read_file();
if(c==3)
search();
if(c==4)
modify();
if(c==5)
Delete();
}while(c!=6);
getche();
}
void write_file()
{
ofstream a("jwellery.dat",ios::binary|ios::app);
g.getdata();
a.write((char*)&g,sizeof(g));
a.close();
}
void read_file()
{
ifstream b("jwellery.dat",ios::binary);
while(b.read((char*)&g,sizeof(g)))
{
g.putdata();
}
b.close();
getche();
}
void search()
{
int p=-1,r;
cout<<"Enter Itemcode-";
cin>>r;
ifstream c("jwellery.dat",ios::binary);
while(c.read((char*)&g,sizeof(g)))
{
if(g.getcode()==r)
{g.putdata();
p++;
}}
c.close();
if(p==-1)
cout<<"Result not found!!!";
getche();
}
void modify()
{
int p=-1,r,t=0;
cout<<"Enter Itemcode-";
cin>>r;
fstream d("jwellery.dat",ios::binary|ios::in|ios::out);
while(d.read((char*)&g,sizeof(g)))
{
t++;
if(g.getcode()==r)
{cout<<"Enter new details"<<endl;
g.getdata();
d.seekp((t-1)*sizeof(g),ios::beg);
d.write((char*)&g,sizeof(g));
p++;
}}
if(p==-1)
cout<<"Result not found!!!";
d.close();
getche();
}
void Delete()
{
int p=-1,r;
cout<<"Enter Itemcode-";
cin>>r;
ifstream e("jwellery.dat",ios::binary);
ofstream f("fun.dat",ios::binary);
while(e.read((char*)&g,sizeof(g)))
{
if(g.getcode()!=r)
{
p++;
f.write((char*)&g,sizeof(g));
}}
e.close();
f.close();
remove("jwellery.dat");
rename("fun.dat","jwellery.dat");
getche();
}
void silver1()
{
int c; clrscr();
void write_file1();
void read_file1();
void search1();
void modify1();
void Delete1();
do
{
cout<<" SILVER MENU"<<"\n 1.Write"<<"\n 2.Read"<<"\n 3.Search"
<<"\n 4.Modify"<<"\n 5,Delete"<<"\n 6.Exit"<< "\n Enter your choice-";
cin>>c;
if (c==1)
write_file1();
if(c==2)
read_file1();
if(c==3)
search1();
if(c==4)
modify1();
if(c==5)
Delete1();
}while(c!=6);
getche();
}
void write_file1()
{
ofstream a("jwellery.dat",ios::binary|ios::app);
s.getdata1();
a.write((char*)&s,sizeof(s));
a.close();
}
void read_file1()
{
ifstream b("jwellery.dat",ios::binary);
while(b.read((char*)&s,sizeof(s)))
{
s.putdata1();
}
b.close();
getche();
}
void search1()
{
int p=-1,r;
cout<<"Enter Itemcode-";
cin>>r;
ifstream c("jwellery.dat",ios::binary);
while(c.read((char*)&s,sizeof(s)))
{
if(s.getcode1()==r)
{s.putdata1();
p++;
}}
c.close();
if(p==-1)
cout<<"Result not found!!!";
getche();
}
void modify1()
{
int p=-1,r,t=0;
cout<<"Enter Itemcode-";
cin>>r;
fstream d("jwellery.dat",ios::binary|ios::in|ios::out);
while(d.read((char*)&s,sizeof(s)))
{
t++;
if(s.getcode1()==r)
{cout<<"Enter new details"<<endl;
s.getdata1();
d.seekp((t-1)*sizeof(s),ios::beg);
d.write((char*)&s,sizeof(s));
p++;
}}
if(p==-1)
cout<<"Result not found!!!";
d.close();
getche();
}
void Delete1()
{
int p=-1,r;
cout<<"Enter Itemcode-";
cin>>r;
ifstream e("jwellery.dat",ios::binary);
ofstream f("fun.dat",ios::binary);
while(e.read((char*)&s,sizeof(s)))
{
if(s.getcode1()!=r)
{
p++;
f.write((char*)&s,sizeof(s));
}}
e.close();
f.close();
remove("jwellery.dat");
rename("fun.dat","jwellery.dat");
getche();
}
void diamond1()
{
int c; clrscr();
void write_file2();
void read_file2();
void search2();
void modify2();
void Delete2();
do
{
cout<<" DIAMOND MENU"<<"\n 1.Write"<<"\n 2.Read"<<"\n 3.Search"
<<"\n 4.Modify"<<"\n 5,Delete"<<"\n 6.Exit"<< "\n Enter your choice-";
cin>>c;
if (c==1)
write_file2();
if(c==2)
read_file2();
if(c==3)
search2();
if(c==4)
modify2();
if(c==5)
Delete2();
}while(c!=6);
getche();
}
void write_file2()
{
ofstream a("jwellery.dat",ios::binary|ios::app);
d.getdata2();
a.write((char*)&d,sizeof(d));
a.close();
}
void read_file2()
{
ifstream b("jwellery.dat",ios::binary);
while(b.read((char*)&d,sizeof(d)))
{
d.putdata2();
}
b.close();
getche();
}
void search2()
{
int p=-1,r;
cout<<"Enter Itemcode-";
cin>>r;
ifstream c("jwellery.dat",ios::binary);
while(c.read((char*)&d,sizeof(d)))
{
if(d.getcode2()==r)
{d.putdata2();
p++;
}}
c.close();
if(p==-1)
cout<<"Result not found!!!";
getche();
}
void modify2()
{
int p=-1,r,t=0;
cout<<"Enter Itemcode-";
cin>>r;
fstream e("jwellery.dat",ios::binary|ios::in|ios::out);
while(e.read((char*)&d,sizeof(d)))
{
t++;
if(d.getcode2()==r)
{cout<<"Enter new details"<<endl;
d.getdata2();
e.seekp((t-1)*sizeof(d),ios::beg);
e.write((char*)&d,sizeof(d));
p++;
}}
if(p==-1)
cout<<"Result not found!!!";
e.close();
getche();
}
void Delete2()
{
int p=-1,r;
cout<<"Enter Itemcode-";
cin>>r;
ifstream k("jwellery.dat",ios::binary);
ofstream f("fun.dat",ios::binary);
while(k.read((char*)&d,sizeof(d)))
{
if(d.getcode2()!=r)
{
p++;
f.write((char*)&d,sizeof(d));
}}
k.close();
f.close();
remove("jwellery.dat");
rename("fun.dat","jwellery.dat");
getche();
}
void purchase1()
{
int c; clrscr();
void write_file4();
void read_file4();
void search4();
void modify4();
void Delete4();
do
{
cout<<" PURCHASE MENU"<<"\n 1.Enter"<<"\n 2.Display"<<"\n 3.Search"
<<"\n 4.Modify"<<"\n 5,Delete"<<"\n 6.Exit"<< "\n Enter your choice-";
cin>>c;
if (c==1)
write_file4();
if(c==2)
read_file4();
if(c==3)
search4();
if(c==4)
modify4();
if(c==5)
Delete4();
}while(c!=6);
getche();
}
void write_file4()
{
ofstream a("jwellery.dat",ios::binary|ios::app);
k.getdata4();
a.write((char*)&k,sizeof(k));
a.close();
}
void read_file4()
{
ifstream b("jwellery.dat",ios::binary);
while(b.read((char*)&k,sizeof(k)))
{
k.putdata4();
}
b.close();
getche();
}
void search4()
{
int p=-1,r;
cout<<"Enter Sellerid-";
cin>>r;
ifstream c("jwellery.dat",ios::binary);
while(c.read((char*)&k,sizeof(k)))
{
if(k.getcode4()==r)
{k.putdata4();
p++;
}}
c.close();
if(p==-1)
cout<<"Result not found!!!";
getche();
}
void modify4()
{
int p=-1,r,t=0;
cout<<"Enter Sellerid-";
cin>>r;
fstream d("jwellery.dat",ios::binary|ios::in|ios::out);
while(d.read((char*)&k,sizeof(k)))
{
t++;
if(k.getcode4()==r)
{cout<<"Enter new details"<<endl;
k.getdata4();
d.seekp((t-1)*sizeof(k),ios::beg);
d.write((char*)&k,sizeof(k));
p++;
}}
if(p==-1)
cout<<"Result not found!!!";
d.close();
getche();
}
void Delete4()
{
int p=-1,r;
cout<<"Enter Sellerid-";
cin>>r;
ifstream e("jwellery.dat",ios::binary);
ofstream f("fun.dat",ios::binary);
while(e.read((char*)&k,sizeof(k)))
{
if(k.getcode4()!=r)
{
p++;
f.write((char*)&k,sizeof(k));
}}
e.close();
f.close();
remove("jwellery.dat");
rename("fun.dat","jwellery.dat");
getche();
}
void sale1()
{
int c; clrscr();
void write_file3();
void read_file3();
void search3();
void modify3();
void Delete3();
do
{
cout<<" SALE MENU"<<"\n 1.Enter"<<"\n 2.Display"<<"\n 3.Search"
<<"\n 4.Modify"<<"\n 5,Delete"<<"\n 6.Exit"<< "\n Enter your choice-";
cin>>c;
if (c==1)
write_file3();
if(c==2)
read_file3();
if(c==3)
search3();
if(c==4)
modify3();
if(c==5)
Delete3();
}while(c!=6);
getche();
}
void write_file3()
{
ofstream a("jwellery.dat",ios::binary|ios::app);
n.getdata3();
a.write((char*)&n,sizeof(n));
a.close();
}
void read_file3()
{
ifstream b("jwellery.dat",ios::binary);
while(b.read((char*)&n,sizeof(n)))
{
n.putdata3();
}
b.close();
getche();
}
void search3()
{
int p=-1,r;
cout<<"Enter Customerid-";
cin>>r;
ifstream c("jwellery.dat",ios::binary);
while(c.read((char*)&n,sizeof(n)))
{
if(n.getcode3()==r)
{n.putdata3();
p++;
}
}
c.close();
if(p==-1)
cout<<"Result not found!!!";
getche();
}
void modify3()
{
int p=-1,r,t=0;
cout<<"Enter Customerid-";
cin>>r;
fstream d("jwellery.dat",ios::binary|ios::in|ios::out);
while(d.read((char*)&n,sizeof(n)))
{
t++;
if(n.getcode3()==r)
{cout<<"Enter new details"<<endl;
n.getdata3();
d.seekp((t-1)*sizeof(n),ios::beg);
d.write((char*)&n,sizeof(n));
p++;
}}
if(p==-1)
cout<<"Result not found!!!";
d.close();
getche();
}
void Delete3()
{
int p=-1,r;
cout<<"Enter Customerid-";
cin>>r;
ifstream e("jwellery.dat",ios::binary);
ofstream f("fun.dat",ios::binary);
while(e.read((char*)&n,sizeof(n)))
{
if(n.getcode3()!=r)
{
p++;
f.write((char*)&n,sizeof(n));
}}
e.close();
f.close();
remove("jwellery.dat");
rename("fun.dat","jwellery.dat");
getche();
}