0% found this document useful (0 votes)
116 views13 pages

CS SuperMarket Source Code

This C++ program is a supermarket billing system that allows users to create products, view products, place orders, generate bills, and perform administrative tasks like modifying and deleting products. The main functions include writing products to a data file, displaying products from the file, placing orders and calculating totals, and an administrator menu to manage the product database through options like add, view, modify, and delete. The code uses classes and object-oriented concepts to model products and implement the various operations.

Uploaded by

Anand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views13 pages

CS SuperMarket Source Code

This C++ program is a supermarket billing system that allows users to create products, view products, place orders, generate bills, and perform administrative tasks like modifying and deleting products. The main functions include writing products to a data file, displaying products from the file, placing orders and calculating totals, and an administrator menu to manage the product database through options like add, view, modify, and delete. The code uses classes and object-oriented concepts to model products and implement the various operations.

Uploaded by

Anand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

//C++ Super Market Billing Project 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()

cout<<"\n\nPlease Enter The Product No. of The Product ";

cin>>pno;

cout<<"\nPlease Enter The Name of The Product ";

gets(name);

cout<<"\nPlease Enter The Price of The Product ";

cin>>price;

cout<<"\nPlease Enter The Discount (%) ";

cin>>dis;

return 0;

}
int show_product()

cout<<"\nThe Product No. of The Product : "<< pno;

cout<<"\nThe Name of The Product : ";

puts(name);

cout<<"\nThe Price of The Product : " <<price;

cout<<"\nDiscount : "<<dis;

return 0;

int retpno ()

return pno;

float retprice()

return price;

char* retname ()

return name;

float retdis ()

return dis;

}pr; //object declaration

int write_product()

fp.open("Billing.dat", ios::out|ios::app);
pr.create_product();

fp.write((char*)&pr,sizeof(product));

fp.close();

cout<<"\n\nThe Product Has Been Created ";

getch();

return 0;

//***************************************************************

// function to read specific record from file

//****************************************************************

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)

cout<<"\n\nrecord not exist";

getch();

//***************************************************************

// function to modify record of file

//****************************************************************

void modify_product()
{

int no,found=0;

cout<<"\n\n\tTo Modify ";

cout<<"\n\n\tPlease Enter The Product No. of The Product ";

cin>>no;

fp.open("Billing.dat",ios::in|ios::out);

while(fp.read((char*)&pr,sizeof(product)) && found==0)

if(pr.retpno()==no)

pr.show_product();

cout<<"\nPlease Enter The New Details of Product "<<endl;

pr.create_product();

int pos=-1*sizeof(pr);

fp.seekp(pos,ios::cur);

fp.write((char*)&pr,sizeof(product));

cout<<"\n\n\t Record Updated";

found=1;

} }

fp.close();

if(found==0)

cout<<"\n\n Record Not Found ";

getch();

//***************************************************************

// function to delete record of file

//****************************************************************

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");

cout<<"\n\n\tRecord Deleted ..";

getch();

//***************************************************************

// function to display all products price list

//****************************************************************

void menu()

fp.open("Billing.dat",ios::in);

if(!fp)

cout<<"ERROR!!! FILE COULD NOT OPEN\n\n\n Go To Admin Menu to create File";

cout<<"\n\n\n Program is closing ....";


getch();

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();

//***************************************************************

// function to place order and generating bill for Products

//****************************************************************

void place_order()

int order_arr[50],quan[50],c=0;

float amt,damt,total=0;

char ch='Y';

menu();

cout<<"\n PLACE YOUR ORDER";

do{

cout<<"\n\nEnter The Product No. Of The Product : ";

cin>>order_arr[c];

cout<<"\nQuantity in number : ";


cin>>quan[c];

c++;

cout<<"\nDo You Want To Order Another Product ? (y/n)";

cin>>ch;

}while(ch=='y' ||ch=='Y');

cout<<"\n\nThank You For Placing The Order";getch();

cout<<"\n\n********************************INVOICE********************
****\n";

cout<<"\nPr No.\tPr Name\tQuantity \tPrice \tGross \tNet Amount\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()

cout<<"C++ PROJECT ON SUPER MARKET BILLING SYSTEM ";

cout<<"\n\n\t\t MADE BY : ANAND ";

cout<<"\n\t SCHOOL : KENDRIYA VIDYALAYA NO. 2 ";

//***************************************************************

// ADMINSTRATOR MENU FUNCTION

//****************************************************************

void admin_menu()

char ch2;

cout<<"\n\n\n\t MENU";

cout<<"\n\n\t1.CREATE PRODUCT";

cout<<"\n\n\t2.DISPLAY ALL PRODUCTS";

cout<<"\n\n\t3.QUERY ";

cout<<"\n\n\t4.MODIFY PRODUCT";

cout<<"\n\n\t5.DELETE PRODUCT";

cout<<"\n\n\t6.EXIT";

cout<<"\n\n\tPlease Enter Your Choice (1-6) ";

cin>>ch2;

switch(ch2)

case '1': write_product();

break;

case '2': menu();


break;

case '3': int num;

cout<<"\n\n\tPlease Enter The Product No. ";

cin>>num;

display_sp(num);

break;

case '4': modify_product();

break;

case '5': delete_product();

break;

case '6': exit(0);

default: cout<<"\nOops!! Wrong Choice...Try Again\n\n";

admin_menu();

//***************************************************************

// THE MAIN FUNCTION OF PROGRAM

//****************************************************************

int main()

{ clrscr();

char ch;

intro(); //call to introduction

cout<<"\n\n\n\tMAIN MENU";

cout<<"\n\n\t01. CUSTOMER";

cout<<"\n\n\t02. ADMINISTRATOR";

cout<<"\n\n\t03. EXIT";

cout<<"\n\n\tPlease Select Your Option (1-3) ";

cin>>ch;

switch(ch)
{

case '1': place_order();

getch();

break;

case '2': admin_menu();

break;

case '3': exit(0);

default :cout<<"\a";

return 0;

OUTPUT
..

You might also like