You are currently viewing Shop Billing System using C++ (With Source Code)

Shop Billing System using C++ (With Source Code)

Shop Billing System using C++ (With Source Code)

Hello, coders. Welcome to the codewithrandom blog. In this article, we will learn how to create a Shop Billing System using C++ (With Source Code).A shoping Billing system store,manages all the entries of the users.

Shop Billing System Using C++

A Shop Billing System implemented in C++ is a basic system which deals with the bill calculation of items in a shop. It has an admin login system. All transactions may be simply managed and viewed by the administrator. Users may input new item entries, see past entries, and compute VAT and payment summary for each entry. Classes are used throughout the program to manage item information, make computations, and handle input/output actions. It also has password security to limit access. This system is easy to create and understand.

Creating Advanced Calculator using C++ (Source Code)

Functionality of the Shop Billing system:

When it comes to the Shop Billing system’s functionality, the user may produce a total bill for an item by inputting the number of items, name, quantity, and price per item. After that, the system creates a total sum including VAT, requests payment, and presents the entire return amount to the user. The last feature is a list of all transactions that have a transaction id.

Features of the system:

  • Users may input new item entries,
  • see past entries, and
  • compute VAT and payment summary for each entry. Classes are used throughout the programme to manage item information, make computations, and handle input/output actions. It also has password security to limit access.

Overview of the UI:

ENTER THE PASSWORD:
  • User will enter the password and then the main menu will appear:
——————————
Shop Billing Management System
——————————
What you want to do?
1.To enter new entry
2.To view previous entries
3.Exit
Enter your option:

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.

Shop Billing System 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<process.h>
#include<fstream>
#include <stdlib.h>
using namespace std;

class head
{
    char Iname[50][50];

public:
    int totalitems;
    float Qty[3];
    float price[3];
    int vatprice[3];
    int tprice[3];
    void input();
    void output();
};
class vat:public head
{
    float vats;
public:
    void vatcal();
    void outputs();
    void sum();
};

//******************************************************************
//	    INPUT FUNCTION
//******************************************************************

void head::input()
{
    system("CLS");
    cout<<"\nEnter number of items= ";
    cin>>totalitems;

    for(int i=0; i<totalitems; i++)
    {
        cout<<"\nEnter name of item "<<i+1<<": ";
        cin>>Iname[i];
        cout<<"Enter quantity: ";
        cin>>Qty[i];
        cout<<"Enter price of item "<<i+1<<": ";
        cin>>price[i];
        tprice[i]=Qty[i]*price[i];
    }
}

//******************************************************************
//	   OUTPUT FUNCTION
//******************************************************************



void head::output()
{
    int a;

    ifstream infile("COUNT.TXT");
    infile>>a;

    ofstream outfile("COUNT.TXT");
    a+=1;
    outfile<<a;
    outfile.close();

    {ofstream outfile("HIS.TXT", ios::app);
    outfile<<endl<<"Bill No.: "<<a<<endl;
    outfile<<"------------------------------------------------------------------------"<<endl;
cout<<"\n";
    cout<<"Name of Item\tQuantity   Price  Total Price\n";
    for(int i=0;i<totalitems;i++)
    {
        outfile<<"Name: "<<Iname[i]<<" Qty: "<<Qty[i]<<" Price: "<<tprice[i]<<endl;
        cout<<Iname[i]<<"\t\t"<<Qty[i]<<"\t   "<<price[i]<<"\t   "<<tprice[i]<<'\n';
    }

    outfile<<"------------------------------------------------------------------------"<<endl;
    outfile.close();
    }
}


//******************************************************************
//	   VAT CALCULATION
//******************************************************************

void vat::vatcal()
{
    input();
    for(int i=0;i<totalitems;i++)
    {
        if(price[i]<=100.00)
        {
            vatprice[i]=tprice[i]+(0.03*tprice[i]);
        }
        else
        {
            vatprice[i]=tprice[i]+(0.1*tprice[i]);
        }
    }
}
//******************************************************************
//	    VAT OUTPUTS
//******************************************************************

void vat::outputs()
{
    output();

    float cash=0,sum=0,qty=0,sumt=0;

    for(int i=0;i<totalitems;i++)
    {
           sumt+=tprice[i];
           sum+=vatprice[i];
           qty+=Qty[i];
    }
    cout<<"\nTotal:";
    cout<<"\n------------------------------------------------------------------------------";
    cout<<"\n\tQuantity= "<<qty<<"\t\t Sum= "<<sumt<<"\tWith Vat:"<<sum;
    cout<<"\n------------------------------------------------------------------------------";

pay:

    cout<<"\n\n\t\t\t****PAYMENT SUMMARY****\n";
    cout<<"\n\t\t\tTotal cash given: ";
    cin>>cash;

    if(cash>=sum)
        cout<<"\n\t\t\tTotal cash repaid: "<<cash-sum<<'\n';
        
    else
    {	cout<<"\n\t\t\tCash given is less than total amount!!!";

    goto pay;
    }
}


//******************************************************************
//	    PROTECTION PASSWORD
//******************************************************************

int passwords()
{

    char p1,p2,p3;

    cout<<"\n\n\n\n\n\n\t\t\tENTER THE PASSWORD: ";

    cin>>p1;
    cout<<"*";
    cin>>p2;
    cout<<"*";
    cin>>p3;
    cout<<"*";

    if ((p1=='s'||p1=='S')&&(p2=='i'||p2=='I')&&(p3=='d'||p3=='D'))

        return 1;

    else
        return 0;
}
// END of Password.

//****************************************************************
//    	THE MAIN FUNCTION OF PROGRAM
//****************************************************************


int main()
{
    vat obj;
    char opt, ch;
    int a=1;
    ifstream fin;

    a==passwords();
    if(!a)
    {
        for(int i=0;i<2;i++)
        {
            cout<<"\nWrong password try once more\n";
            if(passwords())
            {
                goto last;
            }
            else
            {
                cout<<"\n\n\t\t\t all attempts failed.....";
                cout<<"\n\n\n\t\t\t see you.................. ";
                exit(0);
            }

        }
        cout<<"\t\t\t sorry all attempts failed............. \n \t\t\tinactive";
             }
    else{
last:;


     do{
start:
    system("PAUSE");
    system("CLS");
    cout<<"\n\n\t\t\t------------------------------";
    cout<<"\n\t\t\tShop Billing Management System";
    cout<<"\n\t\t\t------------------------------";
     cout<<"\n\n\t\t\tWhat you want to do?";
     cout<<"\n\t\t\t1.\tTo enter new entry\n\t\t\t2.\tTo view previous entries\n\t\t\t3.\tExit\n";
     cout<<"\n\nEnter your option: ";
     cin>>opt;
     switch(opt)
     {
     case'1':
         obj.vatcal();

         obj.outputs();
         goto start;
     case'2':

         fin.open("HIS.TXT", ios::in);
         while(fin.get(ch))
         {
             cout<<ch;
         }
         fin.close();

         goto start;
     case'3':
         exit(0);
     default:
         cout<<"\a";
     }

     }while(opt!=3);
    }
    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), process.h, fstream, stdlib.h (memory management). These header files provide functions that are required for input/output operations, file management, and other standard library functions.
  • Now we will create classes :
  • Creating a class called head It represents an item’s header information. It has the following member variables: Iname, totalitems, Qty, price, vatprice, and tprice, as well as the following member functions: input() and output(). These are all public members.
  • Now we will define  a class named vat and it will be is derived from the head class. It adds a member variable vats and three member functions: vatcal(),  outputs(), sum().
  • The functions of the class will now be defined outside the class.
  • The input() function will let the user enter details of the order like number of items, name, quantity and price.
  • The output() function will read the details from the text file and display the details on the console. The details will be displayed in a table like format.
  • To get item information, the vatcal() method invokes the input() function. The VAT charge for each item is then calculated depending on its pricing. VAT is computed as 3% of the whole price if the price is less than or equal to 100.00; otherwise, VAT is calculated as 10% of the entire price.
  • To produce the bill, the outputs() method invokes the output() function. The total cash, total price, total quantity, and total price with VAT are then calculated. These values are displayed on the console. It also asks the user for the entire amount of cash supplied, calculates the amount refunded, and warns the user if the cash given is less than the total amount.
  • The passwords() function requests a password from the user. It returns 1 (showing success) if the entered password matches “sid” (case-insensitive); otherwise, it returns 0 (meaning failure).
  • The main() function is the program’s entry point. It makes an obj instance of the vat class. Variables opt, ch, and an are also declared. If the password is successfully supplied (using the passwords() function), it initializes a with 1.
  • If the password is entered incorrectly, the program gives you two more chances to input the proper password. If all efforts fail, the program shows a notice and quits.
  • If the password is entered correctly, the program enters a loop and displays a menu of possibilities to the user. The user has the option of entering a new entry, seeing prior entries, or exiting the program.
  • When the user enters a new entry, obj.vatcal() is called to calculate VAT and obj.outputs() is called to show the bill and payment summary. It then returns to the beginning of the loop.
  • When the user selects “View Previous Entries,” the programme accesses the “HIS.TXT” file and reads the contents character by character, printing them on the console. It then returns to the beginning of the loop.
  • When the user decides to quit the program ,it is terminated. The program will continue to loop until the user chooses to leave.Finally, the main() method returns a value of zero, signifying that.

Creating a School Fees Enquiry System using C++ (With Source Code)

Final Output:-

Here is an example to show how this project works.

Shop Billing System Using C++

Shop Billing System Using C++

Shop Billing System Using C++

Shop Billing System Using C++

Shop Billing System Using C++

Conclusion

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.

Encryption and Decryption project in C++ | C++ program for encryption and decryption of file

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

Thank you.

Happy Reading! 🙂

Follow:CodewithRandom



Leave a Reply