Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

#include<iostream>

using namespace std;

struct Date

int year, month;

};

class Drug {

string Drug_name;

int Drug_Number;

float Price,Quantity;

Date Expire_Date;

public:

void Assign_Drug_name(string Drug_name)

this->Drug_name = Drug_name;

void Assign_Drug_Number(int Drug_Number)

this->Drug_Number = Drug_Number;

void Assign_Quantity(float Quantity)

this->Quantity = Quantity;

void Assign_Expire_Date(int Expire_year, int Expire_month)

Expire_Date.year = Expire_year;

Expire_Date.month = Expire_month;
}

void Assign_Price(float Price)

this->Price = Price;

friend class Pharmacy;

};

class Pharmacy :public Drug {

Drug* P;

int N;

public:

Pharmacy() {

P = NULL;

void Insert_Info() {

system("CLS");

string Drug_name;

int Drug_Number;

float Quantity;

Date Expire_Date;

float Price;

cout << "Number of Drugs to be Added: ";

cin >> N;

P = new Drug[N];

system("CLS");
for (int i = 0; i < N; i++)

cout << "(" << i + 1 << ") Drug Info:\n";

cout << "Drug Name: ";

cin >> Drug_name;

P[i].Assign_Drug_name(Drug_name);

cout << "Drug Number: ";

cin >> Drug_Number;

P[i].Assign_Drug_Number(Drug_Number);

cout << "Quantity: ";

cin >> Quantity;

P[i].Assign_Quantity(Quantity);

cout << "Expire Year: ";

cin >> Expire_Date.year;

cout << "Expire Month: ";

cin >> Expire_Date.month;

P[i].Assign_Expire_Date(Expire_Date.year, Expire_Date.month);

cout << "Price: ";

cin >> Price;

P[i].Assign_Price(Price);

system("pause");

void Prin_Info()

system("CLS");

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

{
cout << "(" << i + 1 << ") Drug Info:\n";

cout << "Drug Name: ";

cout << P[i].Drug_name << endl;;

cout << "Drug Number: ";

cout << P[i].Drug_Number << endl;;

cout << "Quantity: ";

cout << P[i].Quantity << endl;;

cout << "Expire Date: ";

cout << P[i].Expire_Date.month;

cout << "/ " << P[i].Expire_Date.year << endl;

cout << "Price: ";

cout << P[i].Price << endl;

cout << "==============\n";

system("pause");

void _2Month_to_Expire() {

system("CLS");

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

int CurrentDate = (6 * 30 + (2020 * 365));

int Drug_Date = ((P[i].Expire_Date.month * 30) + (P[i].Expire_Date.year * 365));

int Result = ((CurrentDate - Drug_Date) / 30);

if (Result == 6)

cout << "(" << i + 1 << ") Drug Info:\n";

cout << "Drug Name: ";

cout << P[i].Drug_name << endl;;


cout << "Drug Number: ";

cout << P[i].Drug_Number << endl;;

cout << "Quantity: ";

cout << P[i].Quantity << endl;;

cout << "Expire Date: ";

cout << P[i].Expire_Date.month;

cout << "/ " << P[i].Expire_Date.year << endl;;

cout << "Price: ";

cout << P[i].Price << endl;

cout << "==============\n";

system("pause");

float Day_To_Day_Trans(float Yesterday_Quanttiy, float Today_Quantity)

return (Yesterday_Quanttiy - Today_Quantity);

~Pharmacy()

delete P;

system("CLS");

cout << "Program Completed\n";

system("pause");

};
int main() {

Pharmacy Kurdistan;

Start:

system("CLS");

int choice;

cout << "1.Insert Drugs Information.\n2.Print Drugs Information.\n3.Check 2 Month Expire Date
Left.\n";

cout << "4.Day-To-Day Quantity Transaction.\n";

cout << "Your Choice: ";

cin >> choice;

if (choice==1)

Kurdistan.Insert_Info();

else if (choice==2)

Kurdistan.Prin_Info();

else if (choice==3)

Kurdistan._2Month_to_Expire();

else if (choice==4)

system("cls");

float Yesterday_Quantity, Today_Quantity;

cout << "Yesterday Quantity: ";

cin >> Yesterday_Quantity;


cout << "Today Quantity: ";

cin >> Today_Quantity;

cout << "Transaction= ";

cout<<Kurdistan.Day_To_Day_Trans(Yesterday_Quantity,Today_Quantity)<<endl;

system("pause");

else

cout << "\aWronggg Choice\n";

goto Start;

You might also like