Rehman Ullah
Rehman Ullah
class Medicine {
char name[50], batchNo[20], expiryDate[20];
float price;
int quantity;
public:
Medicine() {}
void input() {
cout << "\nEnter Medicine Details:\n";
cout << "Name: "; cin >> name;
cout << "Batch No: "; cin >> batchNo;
cout << "Expiry Date: "; cin >> expiryDate;
cout << "Price: "; cin >> price;
cout << "Quantity: "; cin >> quantity;
}
void display() {
cout << "Name: " << name << "\nBatch: " << batchNo
<< "\nExpiry: " << expiryDate << "\nPrice: " << price
<< "\nQuantity: " << quantity << "\n";
}
const char* getName() { return name; }
float getPrice() { return price; }
int getQuantity() { return quantity; }
void updateQuantity(int soldQty) { quantity -= soldQty; }
};
class Pharmacy {
Medicine inventory[MAX];
int count;
public:
Pharmacy() { count = 0; }
void addMedicine() {
if (count < MAX) {
inventory[count].input();
count++;
cout << "Medicine added successfully!\n";
} else {
cout << "Inventory full!\n";
}
}
void showInventory() {
cout << "\n--- Inventory ---\n";
for (int i = 0; i < count; i++) {
inventory[i].display();
cout << "----------------\n";
}
}
void sellMedicine() {
char name[50];
int quantity;
float total = 0;
int main() {
Pharmacy pharmacy;
int choice;
do {
cout << "\n--- Pharmacy Management System ---\n";
cout << "1. Add Medicine\n2. Show Inventory\n3. Sell Medicine\n4.
Exit\n";
cout << "Enter choice: ";
cin >> choice;
switch (choice) {
case 1: pharmacy.addMedicine(); break;
case 2: pharmacy.showInventory(); break;
case 3: pharmacy.sellMedicine(); break;
case 4: cout << "Exiting...\n"; break;
default: cout << "Invalid choice!\n";
}
} while (choice != 4);
return 0;
}