Anda di halaman 1dari 14

MADE BY SONAM CHAUDHARY

SARDAR PATEL PUBLIC SR. SEC.


SCHOOL KARAWAL NAGAR

Informatics Practices
NAME- SOANM CHAUDHARY

Class XII-Commerce
Section: A
ROLL NO. -9132901

Session 2015-16
Informatics Practices

MADE BY SONAM CHAUDHARY

Certificate:This is to certify that SONAM CHAUDHARY of


class 12th has successfully completed this
Informatics Practices project prewcribed by
MRS. REENA NIGAM during academic session
2015-16.
As per the guide lines issued by central
board of secondary education.
Teacher signature
..

MADE BY SONAM CHAUDHARY

Acknowledgement
I would like to express my special thanks of
gratitude to my teacher
MRS. REENA
NIGAM who gave me the golden opportunity
to do this wonder full project also help me in
doing a lot of research and I came to know
about so many new things I am really thankful
to them.
Secondly I would also like to thank my parents
and friends who helped me a lot in finalising
this
project
within
the
limited
time
framework..

MADE BY SONAM CHAUDHARY

SCHOOL
MANAGEMENT

MADE BY SONAM CHAUDHARY

#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
// define maximum number of patients in a queue
#define MAXPATIENTS 100
// define structure for patient data
using namespace std;
struct patient
{
char FirstName[50];
char LastName[50];
char ID[20];
};
// define class for queue
class queue
{
public:
queue (void);
int AddPatientAtEnd (patient p);
int AddPatientAtBeginning (patient p);
patient GetNextPatient (void);
int RemoveDeadPatient (patient * p);
void OutputList (void);
char DepartmentName[50];
private:
int NumberOfPatients;
patient List[MAXPATIENTS];
};
// declare member functions for queue
queue::queue ()
{
// constructor
NumberOfPatients = 0;
}
int queue::AddPatientAtEnd (patient p)
{

MADE BY SONAM CHAUDHARY


// adds a normal patient to the end of the queue.
// returns 1 if successful, 0 if queue is full.
if (NumberOfPatients >= MAXPATIENTS)
{
// queue is full
return 0;
}
// put in new patient
else
List[NumberOfPatients] = p; NumberOfPatients++;
return 1;
}
int queue::AddPatientAtBeginning (patient p)
{
// adds a critically ill patient to the beginning of the queue.
// returns 1 if successful, 0 if queue is full.
int i;
if (NumberOfPatients >= MAXPATIENTS)
{
// queue is full
return 0;
}
// move all patients one position back in queue
for (i = NumberOfPatients-1; i >= 0; i--)
{
List[i+1] = List[i];
}
// put in new patient
List[0] = p; NumberOfPatients++;
return 1;
}
patient queue::GetNextPatient (void)
{
// gets the patient that is first in the queue.
// returns patient with no ID if queue is empty
int i; patient p;
if (NumberOfPatients == 0)
{
// queue is empty
strcpy(p.ID,"");

MADE BY SONAM CHAUDHARY


return p;
}
// get first patient
p = List[0];
// move all remaining patients one position forward in queue
NumberOfPatients--;
for (i=0; i<NumberOfPatients; i++)
{
List[i] = List[i+1];
}
// return patient
return p;
}
int queue::RemoveDeadPatient (patient * p)
{
// removes a patient from queue.
// returns 1 if successful, 0 if patient not found
int i, j, found = 0;
// search for patient
for (i=0; i<NumberOfPatients; i++)
{
if (stricmp(List[i].ID, p->ID) == 0)
{
// patient found in queue
*p = List[i]; found = 1;
// move all following patients one position forward in queue
NumberOfPatients;
for (j=i; j<NumberOfPatients; j++)
{
List[j] = List[j+1];
}
}
}
return found;
}
void queue::OutputList (void)
{
// lists entire queue on screen
int i;
if (NumberOfPatients == 0)

MADE BY SONAM CHAUDHARY


{
cout << "Queue is empty";
}
else
{
for (i=0; i<NumberOfPatients; i++)
{
cout << "" << List[i].FirstName;
cout << " " << List[i].LastName;
cout << " " << List[i].ID;
}
}
}
// declare functions used by main:
patient InputPatient (void)
{
// this function asks user for patient data.
patient p;
cout << "Please enter data for new patient First name: ";
cin.getline(p.FirstName, sizeof(p.FirstName));
cout << "Last name: ";
cin.getline(p.LastName, sizeof(p.LastName));
cout << "Social security number: ";
cin.getline(p.ID, sizeof(p.ID));
// check if data valid
if (p.FirstName[0]==0 || p.LastName[0]==0 || p.ID[0]==0)
{
// rejected
strcpy(p.ID,"");
cout << "Error: Data not valid. Operation cancelled.";
}
return p;
}
void OutputPatient (patient * p)
{
// this function outputs patient data to the screen
if (p == NULL || p->ID[0]==0)
{
cout << "No patient";

MADE BY SONAM CHAUDHARY


return;
}
else
cout << "Patient data:";
cout << "First name: " << p->FirstName;
cout << "Last name: " << p->LastName;
cout << "Social security number: " << p->ID;
}
void DepartmentMenu (queue * q)
{
// this function defines the user interface with menu for one department
int choice = 0, success; patient p;
while (choice != 6)
{
// clear screen
system("cls");;
// print menu
cout << "Welcome to department: " << q->DepartmentName;
cout << "Please enter your choice: \n" ;
cout << "1: Add normal patient \n";
cout << "2: Add critically ill patient \n";
cout << "3: Take out patient for operation \n";
cout << "4: Remove dead patient from queue \n";
cout << "5: List queue \n";
cout << "6: Change department or exit \n";
cin >>choice;
// get user choice
//choice = ReadNumber();
// do indicated action
switch (choice)
{
case 1: // Add normal patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtEnd(p);
system("cls");
if (success)
{

MADE BY SONAM CHAUDHARY


cout << "Patient added:";
}
else
{
// error
cout << "Error: The queue is full. Cannot add patient:";
}
OutputPatient(&p);
cout << "Press any key";
}
break;
case 2: // Add critically ill patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtBeginning(p);
system("cls");;
if (success)
{
cout << "Patient added:";
}
else
{
// error
cout << "Error: The queue is full. Cannot add patient:";
}
OutputPatient(&p);
cout << "Press any key";
}
break;
case 3: // Take out patient for operation
p = q->GetNextPatient();
system("cls");;
if (p.ID[0])
{
cout << "Patient to operate:";
OutputPatient(&p);}
else
{

MADE BY SONAM CHAUDHARY


cout << "There is no patient to operate.";
}
cout << "Press any key";
break;
case 4: // Remove dead patient from queue
p = InputPatient();
if (p.ID[0])
{
success = q->RemoveDeadPatient(&p);
system("cls");;
if (success)
{
cout << "Patient removed:";
}
else
{
// error
cout << "Error: Cannot find patient:";
}
OutputPatient(&p);
cout << "Press any key";
}
break;
case 5: // List queue
system("cls");;
q->OutputList();
cout << "Press any key";
break;
}
}//close while
}
// main function defining queues and main menu
int main ()
{
int i, MenuChoice = 0;
// define three queues
queue departments[3];

MADE BY SONAM CHAUDHARY


// set department names
strcpy (departments[0].DepartmentName, "Heart clinic");
strcpy (departments[1].DepartmentName, "Lung clinic");
strcpy (departments[2].DepartmentName, "Plastic surgery");
while (MenuChoice != 4)
{
// clear screen
system("cls");;
// print menu
cout << "Welcome to Software City Hospital";
cout << "Please enter your choice:";
for (i = 0; i < 3; i++)
{
// write menu item for department i
cout <<"\n "<< (i+1) << ": " << departments[i].DepartmentName;
}
cout << "\n 4: Exit ";
cin>>MenuChoice;
// get user choice
//MenuChoice = ReadNumber();
// is it a department name?
if (MenuChoice >= 1 && MenuChoice <= 3)
{
// call submenu for department
// (using pointer arithmetics here:)
DepartmentMenu (departments + (MenuChoice-1));
}
}
return 0;
}

OUTPUT

MADE BY SONAM CHAUDHARY

MADE BY SONAM CHAUDHARY

Anda mungkin juga menyukai