C++ PROJECT Supermarket Project
C++ PROJECT Supermarket Project
class product
{
int pno;
char name[50];
float price, qty, tax, dis;
public:
void create_product()
{
cout << "\nPlease Enter The Product No. of The Product ";
cin >> pno;
cout << "\n\nPlease Enter The Name of The Product ";
cin>>gets(name);
cout << "\nPlease Enter The Price of The Product ";
cin >> price;
cout << "\nPlease Enter The Discount (%) ";
cin >> dis;
}
void 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;
}
int retpno()
{
return pno;
}
float retprice()
{
return price;
}
char * retname()
{
return name;
}
int retdis()
{
return dis;
}
}; //class ends here
//***************************************************************
// global declaration for stream object, object
//****************************************************************
fstream fp;
product pr;
//***************************************************************
// function to write in file
//****************************************************************
void write_product()
{
fp.open("Shop.dat", ios::out | ios::app);
pr.create_product();
fp.write((char * ) & pr, sizeof(product));
fp.close();
cout << "\n\nThe Product Has Been Created ";
getch();
}
//***************************************************************
// function to read all records from file
//****************************************************************
void display_all()
{
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;
void menu()
{
fp.open("Shop.dat", ios:: in );
if (!fp)
{
cout << "ERROR!!! FILE COULD NOT BE OPEN\n\n\n Go To Admin Menu to create
File ";
//***************************************************************
// 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============================";
cout << "\n PLACE YOUR ORDER";
cout << "\n============================\n";
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();
fp.close();
}
cout << "\n\n\t\t\t\t\tTOTAL = " << total;
getch();
}
//***************************************************************
// INTRODUCTION FUNCTION
//****************************************************************
void intro()
{
//***************************************************************
// ADMINSTRATOR MENU FUNCTION
//****************************************************************
void admin_menu()
{
char ch2;
cout << "\n\n\n\tADMIN 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.VIEW PRODUCT MENU";
cout << "\n\n\t7.BACK TO MAIN MENU";
cout << "\n\n\tPlease Enter Your Choice (1-7) ";
ch2 = getche();
switch (ch2)
{
case '1':
write_product();
break;
case '2':
display_all();
break;
case '3':
int num;
place_order();
getch();
break;
case '2':
admin_menu();
break;
case '3':
return 0 ;
default:
cout << "\a";
}
} while (ch != '3');
}
//***************************************************************
// END OF PROJECT
//***************************************************************