C++ Program For Store Management System
C++ Program For Store Management System
5. View the total sold items (not fully implemented in this version).
The program uses classes and arrays to store data for items, including their code, quantity, and
price.
#include <iostream>
#include <conio.h> // For getch()
using namespace std;
class Department {
int amount[MAX_ITEMS], price[MAX_ITEMS],
code[MAX_ITEMS]; int last; // Keeps track of the last
item added
public:
Department() {
last = 0;
for (int i = 0; i < MAX_ITEMS; i++) {
amount[i] = 0;
price[i] = 0;
code[i] = 0;
}
}
void addOldItem();
void addNewItem();
void showItems();
void sellItem();
void totalItemsSold();
};
// Add details to an existing
item void
Department::addOldItem() {
int itemCode, quantity;
cout << "\nEnter item code:
"; cin >> itemCode;
cout << "Enter quantity to add:
"; cin >> quantity;
// Sell an item
void Department::sellItem()
{ int itemCode, quantity;
cout << "\nEnter item code:
"; cin >> itemCode;
cout << "Enter quantity to sell:
"; cin >> quantity;
cout << "Item sold successfully. Total: " << quantity* price[i] << endl;
} else {
Cout<<”Not enough Stock Available\n”<<endl;
}
}
cout << "Item not found.\n";
}
int main() {
Department d;
int choice;
do {
cout << "\n--- Menu ---\n";
cout << "1. Show all stored
items\n"; cout << "2. Add an old
item\n";
cout << "3. Add a new
item\n"; cout << "4. Sell an
item\n"; cout << "5. Total
sold items\n"; cout << "6.
Quit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
d.showItems();
break;
case 2:
d.addOldItem();
break;
case 3:
d.addNewItem();
break;
case 4:
d.sellItem();
break;
case 5:
d.totalItemsSold();
break;
case 6:
cout << "Exiting program.\n";
break;
default:
cout << "Invalid choice. Try again.\n";
}
} while (choice != 6);
Menu
4. Sell an item
6. Quit
Enter quantity: 50
Enter price: 20
Menu
4. Sell an item
61 Quit
List of Items