This C++ project for a canteen management system includes functions like customer and product search, display, change, and deletion. This program does a search on the client information kept in the file before allowing the user to submit an order. The software is made for small canteens that need to keep track of their data and have a finite number of patrons and items.
Additionally, customers have the choice of buying the item in the interim. If the customer chooses yes, they will be given the option to input the price for each item and, at the conclusion of the procedure, print invoices for the items they have bought as well as backup their purchased items from the pickup center. The admin will now solely oversee reviewing final bills and enhancing assistance for both new and current clients.
Features of Canteen Management System in C++
- Customer's Menu: In the customer's menu, the administrator may add customer information, show all customers, search records, edit records, and remove records for customers.
- Product's Menu: There are five sections in the products menu that allow the administrator to add new products, view all of the products that are already available, search records in the database, edit product information, and remove products.
- Products Report Generator: The client enters the product number, followed by the amount of each item, and the program calculates the total with tax.
Program Breakdown
struct order
{
int prodid1 ;
char pname1 [ 50 ] ;
char compy1 [ 50 ] ;
int qty1 ;
float price1 , dis1 ;
} o1 [ 50 ] ;
The above code will be going to be our structure of the item in the canteen management system, which will going to have the product id, product name, product company and the price of the product.
int orderk = 0 ;
void middleadminmenu ( ) ;
void copyme ( int k , order order1 [ ] , int q1 , int & c2 ) ;
void intromain ( ) ;
int getproduct ( ) ;
int getcustomers ( ) ;
void display_all ( ) ;
void display_all_cust ( ) ;
void prod_tabular ( ) ;
void modify_record ( int n ) ;
void delete_record ( int n ) ;
void againopenandclose ( ) ;
void againopenandclosecust ( ) ;
int search ( int p ) ;
void changeqty ( int pr1 , int q11 ) ;
void gotoxy ( int x , int y )
{
static HANDLE h = NULL ;
if ( !h )
h = GetStdHandle ( STD_OUTPUT_HANDLE ) ;
COORD c = { x , y } ;
SetConsoleCursorPosition ( h , c ) ;
}
The above-mentioned predefined functions are going to be present in our canteen management system for an university like to modify the record we have modifyrecord which will help in modify the record in the system, deleterecord which will allow the user to delete a entry in the system and so on.
class customer
{
int cust_id ;
char cname [ 25 ] ;
char address [ 35 ] ;
char phno [ 15 ] ;
public :
void modifycust_data ( int n1 , char nm [ 15 ] , char add [ 15 ] , char q [ 15 ] ) ;
int getcustid ( )
{ return cust_id ; }
char * getcustnm ( )
{ return cname ; }
char * getcustadd ( )
{ return address ; }
char * getphno ( )
{ return phno ; };
You can access the customers menu, which is divided into five options, by selecting the administrator module. The first option is CREATE CUSTOMERS DETAILS. Third: SEARCH RECORD(QUERY), Fourth: MODIFY CUSTOMERS RECORDS, fifth: DELETE CUSTOMERS RECORDS. Second: DISPLAY ALL CUSTOMERS DETAILS.
void show_cust ( )
{
gotoxy ( 5 , 7 ) ;
cout < < " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " ;
gotoxy ( 10 , 8 ) ;
cout < < " CUST NO : " ;
gotoxy ( 25 , 8 ) ;
cout < < cust_id ;
gotoxy ( 35 , 8 ) ;
cout < < " NAME OF CUST : " ;
gotoxy ( 54 , 8 ) ;
cout < < cname ;
gotoxy ( 10 , 9 ) ;
cout < < " ADDRESS: " ;
gotoxy ( 25 , 9 ) ;
cout < < address ;
gotoxy ( 10 , 10 ) ;
cout < < " PHONE NO.: " ;
gotoxy ( 25 , 10 ) ;
cout < < phno ;
gotoxy ( 5 , 12 ) ;
cout < < " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " ;
}
The above-mentioned code will use to display the details of the customer which was entered by the customer. The entries like name of the customer, phone number and the address.
void customer : : modifycust_data ( int n1 , char nm [ 15 ] , char add [ 15 ] , char q [ 15 ] )
{
char tmpnm [ 40 ] , tmpnm2 [ 40 ] , tmpnm3 [ 15 ] ;
gotoxy ( 5 , 14 ) ;
cout < < " = = = = = = = = = = = = = = = WANT TO MODIFY = = = = = = = = = = = = = = " ;
gotoxy ( 10 , 15 ) ;
cout < < " CUST NO : " ;
cust_id = n1 ;
gotoxy ( 25 , 15 ) ;
cout < < cust_id ;
gotoxy ( 40 , 15 ) ;
strcpy ( cname , nm ) ;
cout < < " NAME OF CUST : " ;
gotoxy ( 60 , 15 ) ;
cout < < cname ;
gotoxy ( 10 , 17 ) ;
cout < < " Want to change the name of customer " ;
gotoxy ( 50 , 17 ) ;
int flag = 0 ;
while ( 1 )
{
gets ( tmpnm ) ;
if ( strlen ( tmpnm ) != 0 )
{
flag = 1 ;
break ;
}
if ( strlen ( tmpnm ) == 0 )
{ flag = 0 ;
break ;
}
}
if ( flag == 1 )
{ strcpy ( cname , tmpnm ) ;
}
else
{
}
gotoxy ( 1 , 18 ) ;
strcpy ( address , add ) ;
// * * * * * * * * * * * * NAME TO BE MODIFY
cout < < " CUSTOMER ADDRESS : " ;
gotoxy ( 20 , 18 ) ;
cout < < address ;
gotoxy ( 45 , 18 ) ;
cout < < " Want to change the address " ;
gotoxy ( 70 , 18 ) ;
flag = 0 ;
while ( 1 )
{
gets ( tmpnm2 ) ;
if ( strlen ( tmpnm2 ) != 0 )
{
flag = 1 ;
break ;
}
if ( strlen ( tmpnm2 ) == 0 )
{ flag = 0 ;
break ;
}
}
if ( flag == 1 )
{ strcpy ( address , tmpnm2 ) ;
}
// * * * * * * * * * * * * * COMPANY NAME TO BE MODIFIED ENDS HERE
gotoxy ( 5 , 19 ) ;
strcpy ( phno , q ) ;
// * * * * * * * * * * * * * * * * phone no. TO BE MODIFY
cout < < " CUSTOMER PHONE NO. : " ;
gotoxy ( 20 , 18 ) ;
cout < < phno ;
gotoxy ( 45 , 18 ) ;
cout < < " Want to change the phone no. " ;
gotoxy ( 70 , 18 ) ;
flag = 0 ;
while ( 1 )
{
gets ( tmpnm3 ) ;
if ( strlen ( tmpnm3 ) != 0 )
{
flag = 1 ;
break ;
}
if ( strlen ( tmpnm3 ) == 0 )
{ flag = 0 ;
break ;
}
}
if ( flag == 1 )
{ strcpy ( phno , tmpnm3 ) ;
}
// * * * * * * * * * * * * * * * * * MODIFIED ENDS HERE
gotoxy ( 5 , 20 ) ;
cout < < " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " ;
}
The customer can also edit there data entered before by them such as, the name of the customer, phone number and address of the customer and the above code will help in doing so.
void cust_tabular ( )
{
int r = 0 , col = 10 ;
customer cust ;
ifstream inFile ;
inFile.open ( " customer.dat " , ios::binary ) ;
if ( !inFile )
{
cout < < " File could not be open !! Press any Key... " ;
getch ( ) ;
return ;
}
display_all_cust ( ) ;
while ( inFile.read ( ( char * ) &cust , sizeof ( customer ) ) )
{
if ( r <= 12 )
{
r + + ;
cust.showallcust ( col ) ;
col + + ;
}else
{
gotoxy ( 20 , 30 ) ;
cout < < " - - - - - - - - - - - press any key - - - - - - - - - - - - - " ;
getch ( ) ;
system ( " cls " ) ;
display_all_cust ( ) ;
col = 10 ;
r = 0 ;
}
}
inFile.close ( ) ;
getch ( ) ;
}
The changes in the customer data will be displayed in a tabular form by the help of the above code.
void display_all_cust ( )
{
system ( " cls " ) ;
intromain ( ) ;
gotoxy ( 1 , 5 ) ;
cout < < " * * * * * * * * * * * * * * * * * CUSTOMER DETAILS * * * * * * * * * * * * * * * * * * * * * * * " ;
gotoxy ( 1 , 6 ) ;
cout < < " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " ;
gotoxy ( 1 , 7 ) ;
cout < < " CUST.NO " < < setw ( 10 ) < < " NAME " < < setw ( 15 ) < < " ADDRESS " < < setw ( 30 ) < < " PHONE NO " ;
gotoxy ( 1 , 8 ) ;
cout < < " * * * * * * * * * * * * * * * * * CUSTOMER DETAILS * * * * * * * * * * * * * * * * * * * * * * * " ;
}
The system will display all the customers in the canteen management system and above code will help to print or display the details.
void modify_cust_record ( int n )
{
customer cust,temp ;
char tmpnm [ 50 ] , tmpaddress [ 50 ] ;
ifstream inFile ;
int fpos1 = -1 ;
inFile.open ( " customer.dat " , ios::binary ) ;
if ( !inFile )
{
cout < < " File could not be open !! Press any Key... " ;
getch ( ) ;
return ;
}
int flag = 0 ;
while ( inFile.read ( ( char * ) & cust , sizeof ( customer ) ) )
{
if ( cust.getcustid ( ) == n )
{ system ( " cls " ) ;
intromain ( ) ;
cust.showcustdatamulti ( ) ;
flag = 1 ;
}
}
inFile.close ( ) ;
if ( flag == 0 )
cout < < " \ n \ n record not exist " ;
else
{
// * * * * * * * modifying the records starts here
fstream File ;
File.open ( " customer.dat " , ios::binary | ios::in | ios::out ) ;
if ( !File )
{
cout < < " File could not be open !! Press any Key... " ;
getch ( ) ;
return ;
}
while ( File.read ( ( char * ) & cust , sizeof ( customer ) ) )
{
if ( cust.getcustid ( ) == n )
{ fpos1 = ( int ) File.tellg ( ) ;
break ;
}
If the administrator wants to modify the customer records if exist in the record file then it can be done from the above code else the system will flag an error that record does not exist.
void deletecust_record ( int n )
{
customer cust ;
ifstream inFile ;
inFile.open ( " customer.dat " , ios::binary ) ;
if ( !inFile )
{
cout < < " File could not be open !! Press any Key... " ;
getch ( ) ;
return ;
}
int flag = 0 ;
while ( inFile.read ( ( char * ) & cust , sizeof ( customer ) ) )
{
if ( cust.getcustid ( ) == n )
{ system ( " cls " ) ;
intromain ( ) ;
cust.showcustdatamulti ( ) ;
flag = 1 ;
}
}
inFile.close ( ) ;
char ch ;
if ( flag == 0 )
cout < < " \ n \ n record not exist " ;
else
{
// * * * * * * * deletion of the records starts from here
gotoxy ( 1 , 15 ) ;
cout<<" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * " ;
gotoxy ( 5 , 16 ) ;
cout < < " = = = = = = DO YOU WANT TO DELETE THE RECORDS GIVEN ABOVE[YES(Y) OR NO (N) = = = = = = = = " ;
gotoxy ( 2 , 17 ) ;
cin > > ch ;
if ( toupper ( ch ) == ' Y ' )
{
ofstream outFile ;
outFile.open ( " Temp2.dat " , ios::binary ) ;
ifstream objiff ( " customer.dat " , ios::binary ) ;
objiff.seekg ( 0 , ios::beg ) ;
while ( objiff.read ( ( char * ) & cust , sizeof ( customer ) ) )
{
if ( cust.getcustid ( ) != n )
{
outFile.write ( ( char * ) & cust , sizeof ( customer ) ) ;
}
}
outFile.close ( ) ;
objiff.close ( ) ;
remove ( " customer.dat " ) ;
rename ( " Temp2.dat " , " customer.dat " ) ;
againopenandclosecust ( ) ;
gotoxy ( 30 , 20 ) ;
cout < < " - - - - - - - - - - - - - - - - - - - - - - - - Record Deleted - - - - - - - - - - - - - - - - - - - - - - " ;
}
}
getch ( ) ;
}
//* * * * * * * * * * * * * * * * * * * delete record ends * * * * * * * * * * * * * * * * * *
If the administrator wants to delete a specific record from the dataset than above code will help. First the record which has to be deleted it will get searched in the record file and then the system will flag a message that DO YOU WANT TO DELETE THE RECORDS GIVEN ABOVE[YES(Y) OR NO (N) then it will get deleted.
int searchcust ( int p )
{
customer cust ;
int tmprt = 0 ;
ifstream inFile ;
inFile.open ( " customer.dat " , ios::binary ) ;
if ( !inFile )
{
cout < < " File could not be open !! Press any Key... " ;
getch ( ) ;
return -1 ;
}
int flag = 0 ;
while ( inFile.read ( ( char * ) & cust , sizeof ( customer ) ) )
{
if ( cust.getcustid ( ) == p )
{ system ( " cls " ) ;
intromain ( ) ;
cust.showcustdatamulti ( ) ;
flag = 1 ;
tmprt = ( int ) inFile.tellg ( ) ;
break ;
}
}
inFile.close ( ) ;
if ( flag == 0 )
return 1 ;
//cout < < " \ n \ n record not exist " ;
else
{
return tmprt ;
}
}
If the administrator wants to check wheather a customer record exist in the record file of the customer than it can be done with the help of above code and if the customer record does not exist in the record file then the system will flag a message that record not exist.
class product
{
int prodid ;
char name [ 50 ] ;
char company [ 50 ] ;
int qty ;
float price , dis ;
public :
product ( )
{
qty = 0 ;
price = 0 ;
dis = 0 ;
}
The above class is going to be for the products in the canteen. The products menu, which is divided into five choices, may be found in the administrator module. Create products, display all available products, search records, modify products, and delete products are the first four actions.
Output:
* * * * * * * * * * * * * * * * CANTEEN-MANAGEMENT* * * * * * * * * * * * * * * * *
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* * * * * * * * * * * * * * * * * S = Y = S = T = E = M * * * * * * * * * * * * * * * * * *
PROJECT:
- - - - - - - - - - - - - - SCHOOL : STATE ENGINEERING UNIVERSITY - - - - - - - - - - - - - - -
* * * * * CANTEEN * * * * MANAGEMENT * * * * SYSTEM * * * * PROJECT * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
= = = = == = = = = MAIN MENU = = = = = = = = = = =
01. PRODUCTS REPORT GENERATOR
02. ADMINISTRATOR
03. EXIT
= = = = == = = = = = = = = = = = = = = = = = = = = = = =
Please Select Your Option (1-3)
= = = = = = = = = = = = = = = = = ADMIN MENU = = = = = = = = = = = = = = = = = = = =
1.CREATE PRODUCTS
2.DISPLAY ALL PRODUCTS AVAILABLE
3.SEARCH RECORD(QUERY)
4.MODIFY PRODUCTS
5.DELETE PRODUCTS
6.BACK TO MAIN MENU
Please Enter Your Choice (1-6) 1
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PROD NO: 2 NAME OF PROD: Sandwich
COMPANY: Smith&Johns QUANTITY 10
PROD PRICE 45 DISCOUNT 5
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* * * * * * * * * * * * * * * PRODUCTS RECORD SAVED * * * * * * * * * * * * * * *
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PROD NO: 65 NAME OF PROD: Samosa
COMPANY: Canteen QUANTITY 14
PROD PRICE 10 DISCOUNT 0
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PROD NO: 1 NAME OF PROD: Tea
COMPANY: Tata QUANTITY 30
PROD PRICE 15 DISCOUNT 0
* * * * * * * * * * * * * * * PRODUCTS RECORD SAVED * * * * * * * * * * * * * * *
**********************PRODUCTS DETAILS***************************
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PROD.NO NAME COMPANY PRICE QUANTITY DISCOUNT
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
1 Sandwich Smith PHP0 0 0%
2 SandwichSmith&Johns PHP1.19209e-007 2573-1.08421e-019%
16704 PHP1.0842e-019 35849.10844e-044%
256 PHP1.58456e+029 76809.10844e-044%
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PROD NO: 1 NAME OF PROD: Tea
COMPANY: Tata PROD PRICE: 15
DISCOUNT: 0% QUANTITY: 1
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =