| 
        
        
        
       
        
        Please any one remove errors from this c   programme,its hospital database project
       
                  
        #include<iostream.h>#include<conio.h>
 #include<string.h>
 #include<stdlib.h>
 #define MAXPATIENTS 100
 Struct patient
 {
 Char FirstName[50];
 Char LastName[50];
 Char ID[20];
 };
 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];
 };
 Queue::queue ()
 {
 NumberOfPatients = 0;
 }
 Int queue::AddPatientAtEnd (patient p)
 {
 If (NumberOfPatients >= MAXPATIENTS)
 {
 Return 0;
 }
 Else
 List[NumberOfPatients] = p;  NumberOfPatients  ;
 Return 1;
 }
 Int queue::AddPatientAtBeginning (patient p)
 {
 Int I;
 If (NumberOfPatients >= MAXPATIENTS)
 {
 Return 0;
 }
 For (I = NumberOfPatients-1; I >= 0; I--)
 {
 List[i 1] = List[i];
 }
 List[0] = p;  NumberOfPatients  ;
 Return 1;
 }
 Patient queue::GetNextPatient (void)
 {  int I;  patient p;
 If (NumberOfPatients == 0) {
 Strcpy(p.ID," ");
 Return p;}
 P = List[0];
 NumberOfPatients--;
 For (I=0; I<NumberOfPatients; I  )
 {
 List[i] = List[i 1];
 }
 Return p;
 }
 Int queue::RemoveDeadPatient (patient * p)
 {
 Int I, j, found = 0;
 For (I=0; I<NumberOfPatients; I  )
 {
 If (stricmp(List[i].ID, p->ID) == 0)
 {
 *p = List[i];  found = 1;
 NumberOfPatients--;
 For (j=i; j<NumberOfPatients; j  )
 {
 List[j] = List[j 1];
 }
 }
 Return (found);
 }
 Void queue::OutputList(void)
 {
 Int I;
 If(NumberOfPatients == 0)
 {
 Cout<<"Queue is empty";
 }
 Else
 {
 For (I=0; I<NumberOfPatients; I  )
 {
 Cout << " " << List[i].FirstName;
 Cout << " " << List[i].LastName;
 Cout << " " << List[i].ID;
 }
 }
 }
 Patient InputPatient (void)
 {
 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));
 If (p.FirstName[0]==0 || p.LastName[0]==0 || p.ID[0]==0)
 {
 Strcpy(p.ID,"");
 Cout << "Error: Data not valid. Operation cancelled.";
 Getch();
 }
 Return p;
 }
 Void OutputPatient (patient * p)
 {
 If(p==NULL||p->ID[0]==0)
 {
 Cout << "No patient";
 Return;
 }
 Else
 Cout << "Patient data:";
 Cout << "First name: " << p->FirstName;
 Cout << "Last name: " << p->LastName;
 Cout << "Social security number: " << p->ID;
 }
 Int ReadNumber()
 {
 Char buffer[20];
 Cin.getline(buffer, sizeof(buffer));
 Return atoi(buffer);
 }
 Void DepartmentMenu (queue * q)
 {
 Int choice = 0, success;  patient p;
 While (choice != 6)
 {
 Clrscr();
 Cout << "Welcome to department: " << q->DepartmentName;
 Cout << "Please enter your choice:";
 Cout << "1:  Add normal patient";
 Cout << "2:  Add critically ill patient";
 Cout << "3:  Take out patient for operation";
 Cout << "4:  Remove dead patient from queue";
 Cout << "5:  List queue";
 Cout << "6:  Change department or exit";
 Choice = ReadNumber();
 Switch (choice)
 {
 Case 1:   // Add normal patient
 P = InputPatient();
 If (p.ID[0])
 {
 Success = q->AddPatientAtEnd(p);
 Clrscr();
 If (success)
 {
 Cout << "Patient added:";
 }
 Else
 {
 Cout << "Error: The queue is full. Cannot add patient:";
 }
 OutputPatient(&p);
 Cout << "Press any key";
 Getch();
 }
 Break;
 Case 2:
 P = InputPatient();
 If (p.ID[0])
 {
 Success = q->AddPatientAtBeginning(p);
 Clrscr();
 If (success)
 {
 Cout << "Patient added:";
 }
 Else
 {
 Cout << "Error: The queue is full. Cannot add patient:";
 }
 OutputPatient(&p);
 Cout << "Press any key";
 getch();
 }
 Break;
 Case 3:
 P = q->GetNextPatient();
 Clrscr();
 If (p.ID[0])
 {
 Cout << "Patient to operate:";
 OutputPatient(&p);}
 Else
 {
 Cout << "There is no patient to operate.";
 }
 Cout << "Press any key";
 Getch();
 Break;
 Case 4:
 P = InputPatient();
 If (p.ID[0])
 {
 Success = q->RemoveDeadPatient(&p);
 Clrscr();
 If (success)
 {
 Cout << "Patient removed:";
 }
 Else
 {
 Cout << "Error: Cannot find patient:";
 }
 OutputPatient(&p);
 Cout << "Press any key";
 Getch();
 }
 Break;
 Case 5:   // List queue
 Clrscr();
 Q->OutputList();
 Cout << "Press any key";
 Getch();
 Break;
 }
 }
 }
 Void main ()
 {
 Int I,MenuChoice = 0;
 Queue departments[3];
 Strcpy (departments[0].DepartmentName, "Heart clinic");
 Strcpy (departments[1].DepartmentName, "Lung clinic");
 Strcpy (departments[2].DepartmentName, "Plastic surgery");
 While (MenuChoice != 4)
 {
 Clrscr();
 Cout << "Welcome to Software City Hospital";
 Cout << "Please enter your choice:";
 For(I=0;i<3;i  )
 {
 Cout << ""<< (i 1) << ":  " << departments[i].DepartmentName;
 }
 Cout << "4:  Exit";
 MenuChoice = ReadNumber();
 If(MenuChoice>=1&&MenuChoice<=3)
 {
 DepartmentMenu(departments (MenuChoice-1));
 }
 }
 }
 Getch();
 }
 |