0% found this document useful (0 votes)
88 views10 pages

Medical Store Records System

This C++ program implements a medical store records system using a class called medical_store. The class contains private member variables to store information about medicines like name, generic name, expiry date, quantity, price, and rack number. Public member functions are used to set/get these variable values. The main() function uses a menu to allow the user to add, display, search, or remove medicine records by calling respective functions that operate on a medical_store object array.

Uploaded by

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

Medical Store Records System

This C++ program implements a medical store records system using a class called medical_store. The class contains private member variables to store information about medicines like name, generic name, expiry date, quantity, price, and rack number. Public member functions are used to set/get these variable values. The main() function uses a menu to allow the user to add, display, search, or remove medicine records by calling respective functions that operate on a medical_store object array.

Uploaded by

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

*** MEDICAL STORE RECORDS SYSTEM ***

Code :

#include<iostream>

#include<string>

using namespace std;

class medical_store

private:

string Name_of_Medicine;

string Generic_name;

string alternate_name;

string expire_date;

int Quantity;

float price;

int rack_number;

public:

medical_store()//Default constructor

Name_of_Medicine="\0";

Generic_name="\0";

alternate_name="\0";

expire_date="\0";

Quantity=0;

price=0;

rack_number=0;

}
void set_Name_of_Medicine(string mn)

Name_of_Medicine=mn;

void set_Generic_name(string gn)

Generic_name=gn;

void set_alternate_name(string aln)

alternate_name=aln;

void set_expire_date(string ed)

expire_date=ed;

void set_Quantity(int qty)

Quantity=qty;

void set_price(float p)

price=p;

void set_rack_number(int rk)

rack_number=rk;

string get_mn()
{

return Name_of_Medicine;

string get_gn()

return Generic_name;

string get_aln()

return alternate_name;

string get_ed()

return expire_date;

int get_qty()

return Quantity;

float get_p()

return price;

int get_rk()

return rack_number;

void update_quantity()

{
Quantity--;

void operator = (const medical_store& obj)

Name_of_Medicine = obj.Name_of_Medicine;

Generic_name = obj.Generic_name;

alternate_name = obj.alternate_name;

expire_date = obj.expire_date;

Quantity = obj.Quantity;

price = obj.price;

rack_number = obj.rack_number;

};

///// Input

void input(medical_store obj[] , int &n)

string mn, gn, an, date;

int q,rn;

float p;

char op;

do

n++;

system("cls");

cout<<"\n> Enter name of medicine : ";

cin.ignore();

getline(cin,mn);
obj[n].set_Name_of_Medicine(mn);

cout<<"\n> Enter generic name of medicine : ";

getline(cin,gn);

obj[n].set_Generic_name(gn);

cout<<"\n> Enter name of alternative medicine : ";

getline(cin,an);

obj[n].set_alternate_name(an);

cout<<"\n> Enter expiry date (dd-mm-yy) : ";

getline(cin,date);

obj[n].set_expire_date(date);

cout<<"\n> Enter quantity : ";

cin>>q;

obj[n].set_Quantity(q);

cout<<"\n> Enter price : ";

cin>>p;

obj[n].set_price(p);

cout<<"\n> Enter rack number : ";

cin>>rn;

obj[n].set_rack_number(rn);

cout<<"\n\n\t\t\t >> Do you want to add another record [y/n] : ";

cin>>op;

} while(op != 'n' && op != 'N');

///// Display

void display(medical_store obj[] , int n)


{

system("cls");

cout<<"\n\n\n\t\t\t ***** MEDICAL STORE RECORDS SYSTEM ***** \n\n\n";

if(n == -1)

cout<<"\n\t\t\t >> No Records .... ";

else

for(int i=0 ; i<=n ; i++)

cout<<"\n >> Record # " <<i+1 <<endl;

cout<<"\n\t> Medicine Name : " <<obj[i].get_mn() <<"\t\t\t" <<"> Expiry Date :


" <<obj[i].get_ed();;

cout<<"\n\t> Generic Name : " <<obj[i].get_gn() <<"\t\t\t" <<"> Quantity : "


<<obj[i].get_qty();

cout<<"\n\t> Alternative Name : " <<obj[i].get_aln() <<"\t\t\t" <<"> Price : "


<<obj[i].get_p();

cout<<"\n\t\t\t\t\t\t> Rack Number : " <<obj[i].get_rk();

cout<<"\n\t\t\t---------------------------------";

///// Search

void search(medical_store obj[] , int n)

system("cls");

cout<<"\n\n\n\t\t\t ***** MEDICAL STORE RECORDS SYSTEM ***** \n\n\n";

if(n == -1)
cout<<"\n\t\t\t >> No Records .... ";

else

string search_name;

bool found=false;

cout<<"\n\n >> Enter number of medicine to search in store : ";

cin.ignore();

getline(cin,search_name);

for(int i=0 ; i<= n ; i++)

if(obj[i].get_mn() == search_name)

found=true;

cout<<"\n\n >> Record Founded ... " <<endl;

cout<<"\n\t> Medicine Name : " <<obj[i].get_mn() <<"\t\t\t" <<">


Expiry Date : " <<obj[i].get_ed();;

cout<<"\n\t> Generic Name : " <<obj[i].get_gn() <<"\t\t\t" <<">


Quantity : " <<obj[i].get_qty();

cout<<"\n\t> Alternative Name : " <<obj[i].get_aln() <<"\t\t\t" <<">


Price : " <<obj[i].get_p();

cout<<"\n\t\t\t\t\t\t> Rack Number : " <<obj[i].get_rk();

break;

if(!found)

cout<<"\n\n >> Sorry, Record not found ...";

}
///// Remove

void remove(medical_store obj[] , int n)

system("cls");

cout<<"\n\n\n\t\t\t ***** MEDICAL STORE RECORDS SYSTEM ***** \n\n\n";

if(n == -1)

cout<<"\n\t\t\t >> No Records .... ";

else

string del_name;

bool found=false;

cout<<"\n\n >> Enter number of medicine to remove : ";

cin.ignore();

getline(cin,del_name);

for(int i=0 ; i<= n ; i++)

if(obj[i].get_mn() == del_name)

found=true;

obj[i].update_quantity();

cout<<"\n\n\t\t >> One " <<del_name <<" removed ... ";

break;

if(!found)

cout<<"\n\n >> Sorry, Record not found ...";

}
int main()

medical_store m[50];

int SIZE=-1;

char op;

do

system("cls");

cout<<"\n\n\n\t\t\t ***** MEDICAL STORE RECORDS SYSTEM ***** \n\n\n";

cout<<"\n\t\t\t > Press 1 for ADD Medicines "

<<"\n\n\t\t\t > Press 2 to DISPLAY Medicines "

<<"\n\n\t\t\t > Press 3 to SEARCH Medicine "

<<"\n\n\t\t\t > Press 4 to REMOVE Medicine "

<<"\n\n\t\t\t > Press 0 to Exit "

<<"\n\n\t\t\t >> Enter your choice ";

cin>>op;

switch(op)

case '1':

input(m,SIZE); break;

case '2':

display(m,SIZE);

cout<<"\n\n\t\t\t";

system("pause");
break;

case '3':

search(m,SIZE);

cout<<"\n\n\t\t";

system("pause");

break;

case '4':

remove(m,SIZE);

cout<<"\n\n\t\t\t";

system("pause");

break;

case '0':

break;

default:

break;

} while(op != '0');

cout<<"\n\n\t\t >> Program Finished ... ";

You might also like