Department Store Management System With C++

by | May 20, 2023 | Basic Coding, C/C++, Coding

Home » Coding » Department Store Management System With C++

Introduction of the Project

The Department Store Management System with C++ is a project developed to enhance the quality and functionality of businesses of all types in every field. The main idea behind this project is to keep a record of all stock items, add new items, delete old items, and keep track of total sold items as well. The user can add the record of goods, edit the existing record, delete the data, and so on.

 

Objectives

The objective of creating a department store management system with C++ is as follows:

1. Store and manage information about items in the store, including their codes, quantities, and prices.

2. Allow users to perform various operations such as adding new items, adding existing items, selling items, and displaying information.

3. Keep track of the total sale amount and the number of items sold.

4. Provide a user-friendly menu interface for easy interaction with the program.

Requirements

To run this C++ project, you must have the following prerequisites

1. IDE for running and compiling the C++ source code. We would recommend Dev C++ or Code Blocks for a better experience.

2. Familiarity with menu-driven programs and switch statements

3. Understanding of the concept of code reuse and the importance of encapsulation in object-oriented programming.

Source Code

#include<iostream>
#include<conio.h>
using namespace std;
const int var=20;
class STORE
{
int AMT[var],SUB[var],X,Y,Z,amount1;
int code,code1,cod[var],S,last;
public:
float price,price1;
STORE(void);
void TAKEN(void);
void TOTAL(void);
void OLD_ADD(void);
void NEW_ADD(void);
void DISPLAY(void);
};
STORE:: STORE(void)
{ S=0;Y=10;Z=40;last=5;AMT[0]=0;
for(int X=0;X<last;X++)
{ S=S+1;Z=Z+10;
cod[X]=S;
AMT[X]=Y;
SUB[X]=Z;
}
}
void STORE::OLD_ADD(void)
{
cout<<"\nITEM CODE:";
cin>>code1;
cout<<"\nITEM COST:";
cin>>price1;
for(X=0;X<last;X++)
{ if(code1==cod[X])
{ Y=Y+1;
AMT[X]=Y;
SUB[X]=price1;
}



}
}
void STORE::NEW_ADD(void)
{ cout<<"\nITEM CODE:";
cin>>code1;
cout<<"\nQUANTITY OF ITEM:";
cin>>amount1;
cout<<"\nPRICE OF ITEM:";
cin>>price1;
cod[last]=code1;
AMT[last]=amount1;
SUB[last]=price1;
last++;
}
void STORE::DISPLAY(void)
{ for(X=0;X<last;X++)
{
cout<<"\nCODE:"<<cod[X]<<"\t";
cout<<"\nQUANTITY:"<<AMT[X]<<"\t";
cout<<"\nPRICE:"<<SUB[X]<<endl;
}
}
void STORE::TAKEN(void)
{
cout<<"\nPRODUCT CODE:\n";
cin>>code;
cout<<"\nPRODUCT PRICE:\n";
cin>>price;
}
void STORE::TOTAL(void)
{
cout<<"\n\nITEM CODE:"<<code<<"\n\nITEM PRICE:"<<price;
}
int main()
{
STORE d[10];
static int j=0;
int x,i=0,p,s=0;


do{
cout<<"\n\t\tDEPARTMENT STORE MANAGEMENT SYSTEM\n";
cout<<"\nChoose from the given list:\n";
cout<<"\n1. Show all stored items:";
cout<<"\n2. Add an old item:";
cout<<"\n3. Add a new item:";
cout<<"\n4. Sell an item:";
cout<<"\n5. Total sold:";
cout<<"\n6. Show total items sold:";
cout<<"\n7. Quit\n";
cin>>x;
switch(x)
{ case 1: d[i].DISPLAY();
break;
case 2: d[i].OLD_ADD();
d[i].DISPLAY();
break;
case 3: d[i].NEW_ADD();
d[i].DISPLAY();
break;
case 4: d[i].TAKEN();
i++,j++;
break;
case 5:{ cout<<"Total sale:";
s=0;
for(p=0;p<j;p++)
{ s=s+d[p].price;
}
cout<<s;
cout<<"TK.\n";
}
break;
case 6: for(i=0;i<j;i++)
{ d[i].TOTAL();
}
break;
case 7: break;
}
} while(x!=7);
getch();
return 0;
}

Code Explanation

The above-written source code for Department Store Management System with C++ develops an application that is very beneficial to keep a record of all data items in store.

1. The code includes the necessary header files: “iostream” and “conio.h”. The iostream library is used for input/output operations, while conio.h provides functions for console input/output.

2. The code defines a class named STORE which represents a store. Within the STORE class, there are private member variables such as AMT, SUB, X, Y, Z, amount1, code, code1, cod, S, and last.

3. There are also public member functions defined: STORE() (constructor), TAKEN(), TOTAL(), OLD_ADD(), NEW_ADD(), and DISPLAY().

  • The STORE() constructor initializes the values of member variables and arrays.
  • The OLD_ADD() function allows the user to add an existing item to the store. It prompts for an item code and cost, and then updates the quantity and price of the corresponding item.
  • The NEW_ADD() function allows the user to add a new item to the store. It prompts for an item code, quantity, and price, and then adds the item to the store’s inventory.
  • The DISPLAY() function displays the details of all the items in the store, including their code, quantity, and price.
  • The TAKEN() function prompts the user to enter the code and price of an item to be sold.
  • The TOTAL() function displays the code and price of the item being sold.

4. The main() function is the entry point of the program. It creates an array of STORE objects named d with a size of 10. It defines some variables: j for tracking the number of items sold, x for user input, i for array indexing, and p for a loop variable. The code enters a do-while loop that displays a menu of options for the user to choose from.

5.. Depending on the user’s input, the program executes the corresponding case in the switch statement.

  • Case 1 displays all the stored items by calling the DISPLAY() function of the STORE object at index i.
  • Case 2 adds an old item by calling the OLD_ADD() and DISPLAY() functions of the STORE object at index i.
  • Case 3 adds a new item by calling the NEW_ADD() and DISPLAY() functions of the STORE object at index i.
  • Case 4 sells an item by calling the TAKEN() function of the STORE object at index i. The i and j variables are incremented to keep track of the number of items sold.
  • Case 5 calculates and displays the total sale amount by iterating through the d array and summing up the prices of all sold items.
  • Case 6 displays the code and price of all the items sold by iterating through the d array.
  • Case 7 exits the do-while loop, terminating the program.

6. The program continues to run until the user enters 7 to quit. The getch() function is used to hold the console window open until a key is pressed.

Finally, the program returns 0, indicating successful execution. Try to execute the code by modifying it to get a better understanding.

Output

The initial start-up screen shows the main menu with seven options.

The user can choose any option from the seven options given according to the use.

More C++ Projects>>>

You May Also Like To Create…