Canteen Management System using C++

Canteen Management System Free Source Code Using C++

Canteen Management System using C++ (With Source Code)

Hello, coders. Welcome to the codewithrandom blog. In this article, we will learn how to create a Canteen Management System using C++ (With Source Code).

A Canteen Management System is a console based software created using C++ programming langauge. This system consists of functionalities such as purchasing things, displaying details, and maintaining customer information. It is a program which automates and organizes the operations and processes involved in running a canteen or café. It is extensively used in educational institutions, business offices, hospitals, and other organizations that provide large-scale food and item services.

Canteen Management System using C++

This system of canteen management improves efficiency, decreases human mistakes, improves the customer experience, and gives better control and visibility over the canteen’s activities by automating and simplifying canteen operations. It saves both the canteen workers and the clients time and effort, resulting in a more organized and efficient food service atmosphere.

Prison Management System using C++ (With Source Code)

Objective of the System:

The major goal of the canteen management system project is to handle the specifics of the Canteen, Item, and quantities available. The project’s goal is to create an application program that will minimize the amount of manual labour required to manage the Canteen, Customers, and Items. The objective of the system is to automate all the activities of the canteen right from purchases to delivery of food/beverage items. It keeps track of all the information about the Item, Stock, and customers. A program that automates and streamlines the operations and processes involved in running a canteen or café. It is extensively used in educational institutions, business offices, hospitals, and other organisations that provide large-scale food services. This Canteen Management project helps in managing the canteen efficiently by keeping track of inventories, categories, food, payments, etc.

Features of the System:

  • The user can Login using a password.
  • The items menu will be displayed and user can select and buy items of their choice.
  • User can see the canteen details and know more about the canteen.
  • User can check the available quantity of the items in the canteen.
  • The user can exit from the system.

Overview of the UI:

                       Welcome TO GUPTA CANTEEN

Consumer Information

  • Enter your First Name
  • Enter your Last Name
  • Enter Phone Number
  • Enter Bill No.

UI of the menu options:

  1. MENU & PURCHASE
  2. DETAILS
  3. NEW CUSTOMER
  4. QUANTITY AVAILABLE
  5. EXIT
ENTER YOUR CHOICE:
The user will choose an option to perform the operation of their choice. User will then enter a values according to the prompts that will be displayed on the console to perform that operation.

Canteen Management System using C++Source code:

You can directly use this code by copying it in your IDE to understand the working and then can create it by understanding the project.

#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<fstream>
#include<string>
#include<iomanip>
#include<unistd.h>
using namespace std;
int main(){
string fname,lname,smart_card;
char pu;
int bill, menu, biscuit=1000,pepsodent=100,powder=200,munch=1000, shoes=200, tide=500, soap=1000, titan=50, oil=1000, perfume = 1000;
int arr[10], price[10]={10,36,110,10,110,90,1199,17,110,1499},sum=0,total=0;
long long int phone;
ifstream read("passcode.txt");
string a,b;
read>>b;
cout<<"Admin Login: \n";
do{
    cout<<"Password :";
    cin>>a;
}while(a!=b);
cout<<endl;
system("cls");
cout<<"\t\t\t\t\t\t\t\t\t\t\t Welcome TO GUPTA CANTEEN\n";
start:;
cout<<"Consumer Information"<<endl;
cout<<"Enter your First Name"<<endl;
cin>>fname;
cout<<"Enter your Last Name"<<endl;
cin>>lname;
cout<<"Enter Phone Number"<<endl;
cin>>phone;
cout<<"Enter Bill No."<<endl;
cin>>bill;
system("cls");
again:
cout<<"\n\n\n\n\1.MENU & PURCHASE";
cout<<"\n\n\n\2.DETAILS";
cout<<"\n\n\n\3.NEW CUSTOMER";
cout<<"\n\n\n\4.QUANTITY AVAILABLE";
cout<<"\n\n\n\5.EXIT";
cout<<"\n\n\nENTER YOUR CHOICE:";
cin>>menu;
system("cls");
switch (menu)
{
case 1:
    cout<<"\nITEMS\t\t\t\t\t\t\t      RATE(RS)";
      cout<<"\n\n\nBISCUTE\t\t\t\t\t\t\t\t10  ";
      cout<<"\n\nPEPSODENT\t\t\t\t\t\t\t36";
      cout<<"\n\nDENIM POWDER\t\t\t\t\t\t\t110   ";
      cout<<"\n\nMUNCH\t\t\t\t\t\t\t\t10  ";
      cout<<"\n\nPARK AVENUE PERFUME\t\t\t\t\t\t110   ";
      cout<<"\n\nCOCONUT HAIR OIL\t\t\t\t\t\t90  ";
      cout<<"\n\nTITAN WATCH\t\t\t\t\t\t\t1199   ";
      cout<<"\n\nLUX SOAP\t\t\t\t\t\t\t17   ";
      cout<<"\n\nTIDE\t\t\t\t\t\t\t\t110   ";
      cout<<"\n\nREEBOK SHOES\t\t\t\t\t\t\t1499   ";
      cout<<"\n\n\nDO YOU WANT TO PURCHASE(Y/N):\n";
      cin>>pu;
    if(pu=='Y'||pu=='y')
    {
    cout<<"\n\n\n\t\t\t\tPURCHASE LIST";
      bis:;
      cout<<"\nBISCUTE(MAX 30): ";
      cin>>arr[0];
      if(arr[0]>30)
      {
       cout<<"Enter Quantity Smaller than 30";
      getch();
      goto bis;
      }
      else
        biscuit-=arr[0];
    pep:;
      cout<<"\nPEPSODENT(MAX 2): ";
      cin>>arr[1];
       if(arr[1]>2)
      {
       cout<<"Enter Quantity Smaller than 2";
      getch();
      goto pep;
      }
      else
      pepsodent-=arr[1];
      den:;
      cout<<"\nDENIM POWDER(MAX 2): ";
      cin>>arr[2];
      if(arr[2]>2)
      {
       cout<<"Enter Quantity Smaller then 2";
      getch();
      goto den;
      }
      else
      powder-=arr[2];
      mun:;
      cout<<"\nMUNCH(MAX 50): ";
      cin>>arr[3];
 
      if(arr[3]>50)
      {
       cout<<"Enter Quantity Smaller then 50";
      getch();
      goto mun;
      }
      else
      munch-=arr[3];
      park:;
      cout<<"\nPARK AVENUE PERFUME(MAX 2): ";
      cin>>arr[4];
 
      if(arr[4]>2)
      {
       cout<<"Enter Quantity Smaller then 2";
      getch();
      goto park;
      }
      else
      perfume-=arr[4];
      coco:;
      cout<<"\nCOCONUT HAIR OIL(MAX 2): ";
      cin>>arr[5];
 
      if(arr[5]>2)
      {
       cout<<"Enter Quantity Smaller then 2";
      getch();
      goto coco;
      }
      else
      oil-=arr[5];
      titan:;
      cout<<"\nTITAN WATCH(MAX 2): ";
      cin>>arr[6];
 
      if(arr[6]>2)
      {
       cout<<"Enter Quantity Smaller then 2";
      getch();
 
      goto titan;
      }
      else
      titan-=arr[6];
      lux:;
      cout<<"\nLUX SOAP(MAX 10): ";
      cin>>arr[7];
 
      if(arr[7]>10)
      {
       cout<<"Enter Quantity Smaller then 10";
      getch();
      goto lux;
      }
      else
      soap-=arr[7];
      tid:;
      cout<<"\nTIDE(MAX 2): ";
      cin>>arr[8];
 
      if(arr[8]>2)
      {
       cout<<"Enter Quantity Smaller then 2";
      getch();
      goto tid;
      }
      else
      tide-=arr[8];
      ree:;
      cout<<"\nREEBOK SHOES(MAX 4): ";
      cin>>arr[9];
 
      if(arr[9]>4)
      {
       cout<<"Enter Quantity Smaller then 4";
      getch();
      goto ree;
      }
      else
      shoes-=arr[9];
      card:;
    
    cout<<"\n Enter 12 Digit Smart Card Details\n";
    cin>>smart_card;
    system("cls");
      cout<<"\n";
      cout<<"\n\n\t\t\t\t  CASH MEMO\n";
      cout<<"\n\nBILL NO.: "<<bill;
      cout<<"\n\nNAME: ";
      cout<<fname<<" "<<lname;
      cout<<"\n\nPHONE NO.: "<<phone;
      cout<<"\n\nSMART CARD.: xxxx-xxxx-xxxx-"<<smart_card[8]<<smart_card[9]<<smart_card[10]<<smart_card[11];
      cout<<"\n\n\n\n\n";
      cout<<"===============================================================================";
      cout<<"\nITEMS"            <<setw(40)<<"QUANTITY"<<setw(35)<<"PRICE(Rs.)"<<endl;
      cout<<"===============================================================================";
      if(arr[0]>0)
        cout<<"\n\nBISCUTE"        <<setw(38)<<arr[0]<<setw(28)<<"Rs."<<arr[0]*price[0];
      if(arr[1]>0)
        cout<<"\n\nPEPSODENT"        <<setw(36)<<arr[1]<<setw(28)<<"Rs."<<arr[1]*price[1];
      if(arr[2]>0)
        cout<<"\n\nDENIM POWDER"     <<setw(33)<<arr[2]<<setw(28)<<"Rs."<<arr[2]*price[2];
      if(arr[3]>0)
        cout<<"\n\nMUNCH"            <<setw(40)<<arr[3]<<setw(28)<<"Rs."<<arr[3]*price[3];
      if(arr[4]>0)
        cout<<"\n\nPARK AVENUE PERFUME"<<setw(26)<<arr[4]<<setw(28)<<"Rs."<<arr[4]*price[4];
      if(arr[5]>0)
        cout<<"\n\nCOCONUT HAIR OIL" <<setw(29)<<arr[5]<<setw(28)<<"Rs."<<arr[5]*price[5];
      if(arr[6]>0)
        cout<<"\n\nTITAN WATCH"      <<setw(34)<<arr[6]<<setw(28)<<"Rs."<<arr[6]*price[6];
      if(arr[7]>0)
        cout<<"\n\nLUX SOAP"         <<setw(37)<<arr[7]<<setw(28)<<"Rs."<<arr[7]*price[7];
      if(arr[8]>0)
        cout<<"\n\nTIDE"             <<setw(41)<<arr[8]<<setw(28)<<"Rs."<<arr[8]*price[8];
      if(arr[9]>0)
        cout<<"\n\nREEBOK SHOES"     <<setw(33)<<arr[9]<<setw(28)<<"Rs."<<arr[9]*price[9];
    for(int i=0;i<10;i++)
    {
        sum+=arr[i];
        total+=(arr[i]*price[i]);
    }
    cout<<"\n===============================================================================";
        cout<<"\nTOTAL:"<<setw(40)<<sum<<setw(27)<<"Rs."<<total;
        cout<<"\n\nTHANK YOU .\t\t\t     VISIT US AGAIN\n";
    getch();
    goto again;
    }
else
{
    goto again;
}
case 2:
system("cls");
    cout<<"\n\n\n\n\n\t\t\t\tCANTEEN DETAILS";
    cout<<"\n\n#TIMING:\n\n 11 AM TO 02 PM \n 03 PM TO 05 PM";
    cout<<"\n\n#CANTEEN WILL CLOSED ON TUESDAY";
    cout<<"\n\n#GOODS ONCE SOLD WILL NOT BE EXCHANGED/REPLACED";
    cout<<"\n\n#TAKE YOUR SMART CARD WITH YOU";
    cout<<"\n\n#COLLECT YOUR SMART CARD & BILL AFTER PAYMENT";
    cout<<"\n\n#DO NOT BREAK ANY CANTEEN ITEMS";
    getch();
    goto again;
case 3:
system("cls");
    goto start;
case 4:
system("cls"); 
cout<<"\n\t\t\tItems Avaliable in Canteen.\n\n\n";
      cout<<"===============================================================================";
      cout<<"\nITEMS"            <<setw(40)<<"QUANTITY";
      cout<<"\n===============================================================================";
      cout<<"\n\n\nBISCUTE"        <<setw(38)<<biscuit;
      cout<<"\n\n\nPEPSODENT"        <<setw(36)<<pepsodent;
      cout<<"\n\n\nDENIM POWDER"     <<setw(33)<<powder;
      cout<<"\n\n\nMUNCH"            <<setw(40)<<munch;
      cout<<"\n\n\nPARK AVENUE PERFUME"<<setw(26)<<perfume;
      cout<<"\n\n\nCOCONUT HAIR OIL" <<setw(29)<<oil;
      cout<<"\n\n\nTITAN WATCH"      <<setw(34)<<titan;
      cout<<"\n\n\nLUX SOAP"         <<setw(37)<<soap;
      cout<<"\n\n\nTIDE"             <<setw(41)<<tide;
      cout<<"\n\n\nREEBOK SHOES"     <<setw(33)<<shoes;
      cout<<"\n\n*******************************************************************************";
      getch();
      goto again;
case 5:
cout<<"\n\n\n\n\t   THANKS";
    sleep(1);
    system("cls");
    cout<<"\n\n\n\n\n\t\t   THANKS";
    sleep(1);
    system("cls");
    cout<<"\n\n\n\n\n\n\n\t\t\t   THANKS";
    sleep(1);
    system("cls");
    cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t   THANKS";
    sleep(1);
    system("cls");
    cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t   THANKS";
    sleep(1);
    system("cls");
   cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t  THANKS\n\n\n\t\t\t\tPress any key to Exit......."; 
    exit(0);
    getch();
default:
    cout<<"Your Choice is Wrong";
    goto again;
    getch();
}
return 0;
}

Now let us understand the code:-

  • We will start by writing the header of the code with the required libraries –  iostream  (input and output stream), conio.h (console input/output), stdio.h (standard input/output), fstream, string (string manipulation), iomanip (formatting), unistd.h.
  • Now we will create the main() function. The program will start from this point. Here in, we will create variables which will store customer information, menu choices, quantities, prices, and other data. Then we will create arrays named as arr[] and price[] which will be store the quantities and prices of items respectively.
  • We will create a file called “passcode.txt” in the same folder as our cpp file. It will contain the password for this system so that when we login into the system, it reads the password using ifstream from the password.txt file. The password for this project is ‘openit’. The access to this canteen management system will only be granted if the password entered matches with the password in the password.txt file.
  • After successfully logging into the system,  we will clear the screen using – system(“cls”) and then display the welcome message along with the prompt for the user(consumer) to enter their information such as – First name, Last name, Phone number and Bill number. We will then clear the screen again.
  • Then we will display the options of the operations user can perform in this system such as – Menu and purchase, details, adding new customer details, display of quantity available and exit. The user will be asked to enter their choice.
  • We will use switch case statements to select between the options given.
  • Selecting Option 1 will display the menu items a customer can buy. They will be asked if they want to make a purchase or not. If the user wants to make a purchase then press ‘y’ key or ‘n’ for no. Upon choosing ‘y’, user will be displayed with a list of items they can buy by entering the number of quantities they want to buy. Then system will calculate the remaining quantity of each item and displays a cash memo with the bill details, including the items purchased, quantities, smart card number, and total price. The user will be displayed with a thankyou for their purchase message and then returned to the menu.
  • Selecting Option 2 will display the canteen details to the user which will include opening and closing timings, and other necessary details. You can customize these according to your preferences.
  • Selecting Option 3 will first clear the screen and then ask the user to enter the new customer details. The user will be taken to the start of the program and have to enter the customer information.
  • Selecting Option 4 will display the available quantities of the items in the canteen to the user.
  • Selecting Option 5 will exit from the program and display the thanks messages.
  • This sums up our project of Canteen Management System using C++.

Number Guessing Game using C++ (With Source Code)

Final Output:-

Here is an example to show how this project works.

Canteen Management System using C++

Canteen Management System using C++

Canteen Management System using C++

  • Selecting Option 1

Canteen Management System using C++

Canteen Management System using C++

Canteen Management System using C++

  • Selecting Option 2

Canteen Management System using C++

  • Selecting Option 4

Canteen Management System using C++

Conclusion

Congratulations you have just created another major project for you Final year. We have reached the end of this article and have a lot more projects in C++ coming so stay tuned. We have started with awesome and fun projects for you all to understand C++. Learning C++ by creating fun projects makes learning easy and interesting. If you’re a college student the this Canteen Management project Source Code can be helpful for final-year students or college students.

Rock Paper and Scissors Game using C++ (With Source Code)

If you enjoyed the article and learned something new today, let us know in the comments.

Thank you.

Happy Reading! 🙂

ADVERTISEMENT

Follow: CodeWithRandom

ADVERTISEMENT



Leave a Reply