CS SuperMarket Source Code
CS SuperMarket Source Code
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
#include<process.h>
#include<fstream.h>
fstream fp;
class product
int pno;
char name[50];
float price,qty,tax,dis;
public:
int create_product()
cin>>pno;
gets(name);
cin>>price;
cin>>dis;
return 0;
}
int show_product()
puts(name);
cout<<"\nDiscount : "<<dis;
return 0;
int retpno ()
return pno;
float retprice()
return price;
char* retname ()
return name;
float retdis ()
return dis;
int write_product()
fp.open("Billing.dat", ios::out|ios::app);
pr.create_product();
fp.write((char*)&pr,sizeof(product));
fp.close();
getch();
return 0;
//***************************************************************
//****************************************************************
void display_sp(int n)
int flag=0;
fp.open("Billing.dat",ios::in);
while(fp.read((char*)&pr,sizeof(product)))
if(pr.retpno()==n)
pr.show_product();
flag=1;
}}
fp.close();
if(flag==0)
getch();
//***************************************************************
//****************************************************************
void modify_product()
{
int no,found=0;
cin>>no;
fp.open("Billing.dat",ios::in|ios::out);
if(pr.retpno()==no)
pr.show_product();
pr.create_product();
int pos=-1*sizeof(pr);
fp.seekp(pos,ios::cur);
fp.write((char*)&pr,sizeof(product));
found=1;
} }
fp.close();
if(found==0)
getch();
//***************************************************************
//****************************************************************
void delete_product()
int no;
cout<<"\n\n\n\tDelete Record";
cout<<"\n\nPlease Enter The product no. of The Product You Want To Delete\t";
cin>>no;
fp.open("Billing.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Tem.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&pr,sizeof(product)))
if(pr.retpno()!=no)
fp2.write((char*)&pr,sizeof(product));
} }
fp2.close();
fp.close();
remove("Billing.dat");
rename("Tem.dat","Shop.dat");
getch();
//***************************************************************
//****************************************************************
void menu()
fp.open("Billing.dat",ios::in);
if(!fp)
exit(0);
cout<<"\n\n\t\tProduct MENU\n\n";
cout<<"========================================================\n";
cout<<"P.NO.\t\tNAME\t\tPRICE\t\tDISCOUNT\n";
cout<<"========================================================\n";
while(fp.read((char*)&pr,sizeof(product)))
cout<<pr.retpno()<<"\t\t"<<pr.retname()<<"\t\t"<<pr.retprice()<<"\t\t"<<pr.retdis()<
<" %"<<endl;
fp.close();
getch();
//***************************************************************
//****************************************************************
void place_order()
int order_arr[50],quan[50],c=0;
float amt,damt,total=0;
char ch='Y';
menu();
do{
cin>>order_arr[c];
c++;
cin>>ch;
}while(ch=='y' ||ch=='Y');
cout<<"\n\n********************************INVOICE********************
****\n";
for(int x=0;x<=c;x++)
fp.open("Billing.dat",ios::in);
fp.read((char*)&pr,sizeof(product));
while(!fp.eof())
if(pr.retpno()==order_arr[x])
amt=pr.retprice()*quan[x];
damt=amt-(amt*pr.retdis()/100);
cout<<"\n"<<order_arr[x]<<"\t"<<pr.retname()
<<"\t"<<quan[x]<<"\t\t"<<pr.retprice()<<"\t"<<amt<<"\t\t"<<damt;
total+=damt;
fp.read((char*)&pr,sizeof(product));
fp.close();
cout<<"\n\t\t\t\t\tTOTAL = "<<total;
getch();
}
//***************************************************************
// INTRODUCTION FUNCTION
//****************************************************************
void intro()
//***************************************************************
//****************************************************************
void admin_menu()
char ch2;
cout<<"\n\n\n\t MENU";
cout<<"\n\n\t1.CREATE PRODUCT";
cout<<"\n\n\t3.QUERY ";
cout<<"\n\n\t4.MODIFY PRODUCT";
cout<<"\n\n\t5.DELETE PRODUCT";
cout<<"\n\n\t6.EXIT";
cin>>ch2;
switch(ch2)
break;
cin>>num;
display_sp(num);
break;
break;
break;
admin_menu();
//***************************************************************
//****************************************************************
int main()
{ clrscr();
char ch;
cout<<"\n\n\n\tMAIN MENU";
cout<<"\n\n\t01. CUSTOMER";
cout<<"\n\n\t02. ADMINISTRATOR";
cout<<"\n\n\t03. EXIT";
cin>>ch;
switch(ch)
{
getch();
break;
break;
default :cout<<"\a";
return 0;
OUTPUT
..