C++ program for hospital database by harikumaru

VIEWS: 968 PAGES: 3

C++ program for hospital database....................

More Info
									                          HOSPITAL DATABASE



//************************************************************************
// Program Name           :Hospital.cpp
// executable file     :Hospital
// Author           :
// Date Written        :24-03-2010
// Date Compiled         :24-03-2010
// Aim of the Program :Create a Hospital Data base
// Version          :1.0
//************************************************************************
#include<iostream>
using namespace std;
#include<string.h>
class date
{
        private:
                 int dd;
                 int mm;
                 int yy;
        public:
                 void input();
                 void display();
};
class basepatient
{
        private:
                 char name[30];
                 date doa,dod;
        public:
                 char disease[30];
                 void input();
                 void display();
};
class derivedpatient:public basepatient
{
        public:
                 int age;
                 void input();
                 friend void display(derivedpatient,int);
};
void date::input()
{
        cin>>dd>>mm>>yy;
}
void date::display()
{
        cout<<dd<<":"<<mm<<":"<<yy;
}
void basepatient::input()
{
        cout<<"\nEnter Name of Patient:";
        cin>>name;
        cout<<"Enter disease:";
        cin>>disease;
        cout<<"Enter admission date in dd:mm:yy format:";
        doa.input();
        cout<<"Enter dicharge date in dd:mm:yy format:";
        dod.input();
}
void basepatient::display()
{
        cout<<"\nName:";
    cout<<name;
        cout<<"\nAdm.Date:";
        doa.display();
        cout<<"\nDisc.Date";
        dod.display();
        cout<<endl;
}
void derivedpatient::input()
{
        basepatient::input();
        cout<<"\nEnter Age:";
        cin>>age;
}
void display(derivedpatient *p,int n)
{
        cout<<"\nEnter Age and disease:";
        char idisease[30];
        int iage;
        cin>>iage;
        cin>>idisease;
        int cmp,flag=0;
        cout<<"\nChecking for details that match the given details:";
        cout<<"\nAge:"<<iage;
        cout<<"\nDisease:";
    cout<<idisease;
        for(int i=0;i<n;i++)
        {
                 cmp=strcmp(idisease,(p+i)->disease);
                if(iage==(p+i)->age&&cmp==0)
                {
                        (p+i)->basepatient::display();
                        flag++;
                }
        }
        if(flag==0)
                 cout<<"\nNot found";
}
int main()
{
        derivedpatient A[10];
        int N;
        cout<<"Enter number of details you want to enter:";
        cin>>N;
        for(int i=0;i<N;i++)
                 A[i].input();
        display(A,N);
        return (0);
}




       OUTPUT



Enter number of details you want to enter:1

Enter Name of Patient:john
Enter disease: Diabetes
Enter admission date in dd:mm:yy format:20 3 2010
Enter dicharge date in dd:mm:yy format:27 3 2010

Enter Age:30

Enter Age and disease:30 Diabetes

Checking for details that match the given details:
Age:30
Disease: Diabetes
Name:john
Adm.Date:20:3:2010
Disc.Date27:3:2010

								
To top