0% found this document useful (0 votes)
3 views5 pages

Rehman Ullah

The document outlines a Pharmacy Management System implemented in C++. It includes classes for managing medicine details and inventory, allowing users to add medicines, display inventory, and sell medicines while updating quantities. The program features a simple menu-driven interface for user interaction.

Uploaded by

syedex14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Rehman Ullah

The document outlines a Pharmacy Management System implemented in C++. It includes classes for managing medicine details and inventory, allowing users to add medicines, display inventory, and sell medicines while updating quantities. The program features a simple menu-driven interface for user interaction.

Uploaded by

syedex14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Project No # 01

Topic: Pharmacy Management System


Submitted By: Rehman Ullah
Submitted To: Mr. Umair Ali
Course Title: Object Oriented
Programming (CS-103)
Course Code: CS-103
Section: A (Evening)
Registration No: UON-24-1434
Department of Computer Science
UNIVERSITY OF NAROWAL
#include <iostream>
using namespace std;

const int MAX = 100;

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;

cout << "\nEnter Medicine Name to Sell: ";


cin >> name;
cout << "Enter Quantity: ";
cin >> quantity;

for (int i = 0; i < count; i++) {


if (strcmp(inventory[i].getName(), name) == 0) {
if (inventory[i].getQuantity() >= quantity) {
total = inventory[i].getPrice() * quantity;
inventory[i].updateQuantity(quantity);
cout << "Bill: " << total << " PKR\n";
return;
} else {
cout << "Insufficient stock!\n";
return;
}
}
}
cout << "Medicine not found!\n";
}
};

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;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy