Skip to content
Laviyx Learn

Try

Mini project

Shop Inventory and Billing System in C++

A C++ program for a small shop that manages products and stock, creates bills with GST, warns about low stock, and saves products and sales to files.

Intermediate 2–3 weeks 1–2 studentsUpdated

C++17OOPSTL map and vectorfstream

The problem

Small shops need to know what is in stock and produce correct bills quickly. Many still use a notebook and a calculator. This project builds the core of a billing system: products, stock updates on every sale, and a printed bill with tax.

Features to build

  • Add, update, search and remove products (code, name, price, GST rate, quantity)
  • Create a bill: add items by product code and quantity, with a stock check for each item
  • Bill total with each item's amount, GST and grand total, printed in neat columns
  • Reduce stock automatically after each bill
  • Low-stock report for products below a reorder level
  • Save products and past bills to files, and load them on start

Suggested data model

ClassResponsibility
Productcode, name, price, GST percentage, quantity, reorder level
BillItemproduct code, quantity, price at the time of sale
Billbill number, date, std::vector<BillItem>, totals
Inventorystd::map<std::string, Product> keyed by product code, stock rules

Store the price on each bill item, so old bills stay correct after a price change.

Build plan

  1. 1

    Design the classes

    Decide the members and methods of Product, Bill and Inventory. Keep stock changes inside Inventory.

  2. 2

    Inventory with std::map

    Use the product code as the key for fast search, and use find() to check whether a code exists before reading it.

  3. 3

    Billing

    Collect items in a vector, check stock for each one, then calculate amounts. Only reduce stock after the bill is confirmed.

  4. 4

    Formatted output

    Print the bill with std::setw and std::fixed with std::setprecision(2) from iomanip.

  5. 5

    Files

    Save products with ofstream, one product per line, and read them back with ifstream. Handle a missing file on the first run.

  6. 6

    Errors and testing

    Throw exceptions for unknown codes and low stock, catch them in the menu, and test the GST maths by hand.

Learn these first

Each part of the project is taught in one of these free lessons.

Make it stand out

  • Daily sales report: total sales and best-selling products
  • Discounts and coupon codes
  • Separate admin and cashier logins
  • Unit tests for the billing calculations

Viva and interview questions

Try to answer each one aloud before you open it.

  • Why did you use std::map for the inventory?

    Products are looked up by code on every bill. std::map finds a key in logarithmic time and keeps codes sorted, which also gives a sorted product list for free. std::unordered_map would also work with faster average lookups.

  • Why does a bill item store the price?

    Prices change over time. Storing the price at the time of sale keeps old bills correct.

  • How do you calculate GST on an item?

    Item amount is price times quantity. GST is that amount times the GST rate divided by 100. The line total is the amount plus GST.

  • What is the difference between a class and a struct in C++?

    They are the same except for the default access: members of a struct are public by default and members of a class are private.

  • What happens if two cashiers bill the last item at the same time?

    In this single-user program it cannot happen. In a real multi-user system, the stock update would need a database transaction or a lock so only one sale succeeds.

What to put in your project report

  1. Abstract: the problem, your solution and the result in one paragraph.
  2. Introduction and problem statement: who has the problem and why it matters.
  3. Requirements: the features (functional) and qualities such as speed and security (non-functional).
  4. Design: architecture diagram, database tables or data flow, and screen layouts.
  5. Implementation: the main modules and the most interesting code, explained.
  6. Testing: the test cases you ran, with inputs, expected and actual results.
  7. Results: screenshots or numbers that show the project working.
  8. Conclusion and future scope: what you achieved and what you would add next.

Your college may give its own format. Follow that first, and use this list to check nothing is missing.

All project ideas →