0% found this document useful (0 votes)
35 views3 pages

Using Namespace Struct: "PCH.H"

The document defines structures for storing pharmacy medicine data including name, price, quantity, and expiration date. It includes functions for inserting medicine data by prompting the user for input, displaying individual medicine information, and displaying all medicine information by iterating through an array. The main function initializes an array to store medicine data and calls the menu function in a loop to allow the user to insert, view, or delete medicine records.

Uploaded by

notonetab
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)
35 views3 pages

Using Namespace Struct: "PCH.H"

The document defines structures for storing pharmacy medicine data including name, price, quantity, and expiration date. It includes functions for inserting medicine data by prompting the user for input, displaying individual medicine information, and displaying all medicine information by iterating through an array. The main function initializes an array to store medicine data and calls the menu function in a loop to allow the user to insert, view, or delete medicine records.

Uploaded by

notonetab
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/ 3

#include "pch.

h"
#include <iostream>
#include <string>

using namespace std;

struct DATE
{

int day;
int month;
int year;
};

struct PHARMACY
{
string medicineName;
float price;
int quantity;
DATE expiryDate;
};

void insertMedicine(PHARMACY medicine[], int& medicineCount)


{

cout << "\nEnter medicine: ";


cin >> medicine[medicineCount].medicineName;

cout << "Enter price: ";


cin >> medicine[medicineCount].price;

cout << "Enter quantity: ";


cin >> medicine[medicineCount].quantity;

cout << "Enter expire date: " << endl;


cout << "Day: "; cin >> medicine[medicineCount].expiryDate.day;
cout << "Month: "; cin >> medicine[medicineCount].expiryDate.month;
cout << "Year: "; cin >> medicine[medicineCount].expiryDate.year;

medicineCount++;

void showMedicine(PHARMACY medicine)


{

cout << "\nMedicine: " << medicine.medicineName << endl;


cout << "Medicine price: " << medicine.price << endl;
cout << "Medicine quantity: " << medicine.quantity << endl;
cout << "Medicine expire date: " << medicine.expiryDate.day << "." <<
medicine.expiryDate.month << "." << medicine.expiryDate.year << endl;
cout << endl;

void showAllMedicine(PHARMACY medicine[], int medicineCount)


{
cout << "\nYou have entered the following medicine:" << endl;

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


{
showMedicine(medicine[i]);
}
}

void deleteMedicine()
{

void deleteMedicineMenu()
{

bool showMainMenu(PHARMACY medicine[], int& medicineCount) {

int option;
cout << "\nChoose an option from the menu below:" << endl;
cout << "1. Insert a medicine in the list." << endl;
cout << "2. See what medicine we have in the list." << endl;
cout << "3. Delete medicine with expired date" << endl;
cout << "9. Exit." << endl;
cout << "Enter the option, which you want to use: ";

cin >> option;

switch (option)
{
case 1:
insertMedicine(medicine, medicineCount);
break;
case 2:
showAllMedicine(medicine, medicineCount);
break;
case 3:
showMedicineBelowMinMenu(medicine, medicineCount);
break;

case 9:
return false;
}

return true;
}

void main()
{
int medicineCount = 0;

PHARMACY medicine[10];
bool doShowMenu = true;

do {
doShowMenu = showMainMenu(medicine, medicineCount);
} while (doShowMenu);
}

You might also like