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.
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
Store the price on each bill item, so old bills stay correct after a price change.
Build plan
- 1
Design the classes
Decide the members and methods of Product, Bill and Inventory. Keep stock changes inside Inventory.
- 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
Billing
Collect items in a vector, check stock for each one, then calculate amounts. Only reduce stock after the bill is confirmed.
- 4
Formatted output
Print the bill with std::setw and std::fixed with std::setprecision(2) from iomanip.
- 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
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.
- C++ Classes and Objects: Members, Methods, public and private
- C++ Constructors and Destructors: Initializer Lists, explicit and Object Lifetime
- C++ Encapsulation: Private Data, Getters, Setters and Class Invariants
- C++ std::vector: Dynamic Arrays Explained with Examples
- C++ std::map: Key-Value Pairs, Lookup, Insert, Erase and Iteration
- C++ Exceptions: try, catch, throw and Exception Safety
- C++ File Handling: Reading and Writing Files with fstream
- C++ Strings: std::string Operations, Searching, Substrings and Conversion
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::mapfinds a key in logarithmic time and keeps codes sorted, which also gives a sorted product list for free.std::unordered_mapwould 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
- Abstract: the problem, your solution and the result in one paragraph.
- Introduction and problem statement: who has the problem and why it matters.
- Requirements: the features (functional) and qualities such as speed and security (non-functional).
- Design: architecture diagram, database tables or data flow, and screen layouts.
- Implementation: the main modules and the most interesting code, explained.
- Testing: the test cases you ran, with inputs, expected and actual results.
- Results: screenshots or numbers that show the project working.
- 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.