#include<iostream.h>
#include<string.h>
void main()
{
	int ch,n,phy_id[10],phy_workex[22];
	char phy_name[12],phy_spec[30];
	char pat_name[20],pat_gender[10],pat_case[50],ass_phy[12];
	int m,pat_age[4],pat_cardno[20],pat_date[4];
		do
		{
			cout<<"\t\t\t TASK SELECTION WINDOW \n";
			cout<<"\t\t\t ********************* \n";
			cout<<"\t What would you like to do ?\n";
			cout<<"\t Please enter the number you choice \n";
			cout<<"\t 1.Register a physician/s \n";
			cout<<"\t 2.Register a patient/s \n";
			cout<<"\t 3.Edit physician or patient information \n";
			cout<<"\t 4.Delete patient or physician information \n";
			cout<<"\t 5.List all available physicians \n";
			cout<<"\t 6.List all registered patients \n";
			cout<<"\t 7.Search for a patient \n";
			cout<<"\t 8 Search for a physician \n";
			cout<<"\t 9.Quit a program \n";
			cout<<endl;
		
		
cout<<"Please enter your selection !\n";
cin>>ch;

}

switch(ch)
{
case '1':
		cout<<"\t How many physician you want to register ?\n";
		cin>>n;
		cout<<"Enter name,id,specification and work experiance of "<<n<<"physicians"<<endl;
		cout<<"--------------------------------------------------------------"<<endl;
		for(int i=0;i<n;i++)
		{
			cout<<"\nEnter physician "<<i<<"name :";
			cin>>phy_name[i];
			cout<<"Enter physician "<<i<<"id :";
			cin>>phy_id[i];
			cout<<"\nEnter physician "<<i<<"specification :";
			cin>>phy_spec[i];
			cout<<"\n Enter physician "<<i<<"work experiance :";
			cin>>phy_workex[i];
			cout<<endl;
		}
		break;
case 2:
		cout<<"\t How many patient you want to register ?\n";
		cin>>m;
		cout<<"Enter name,age,gender,card no,case,date and assigned physician of"<<m<<"patients"<<endl;
		cout<<"-------------------------------------------------------------------------"<<endl;
		for(int j=0;j<m;j++)
		{
			cout<<"\n Enter patient "<<i<<"name :";
			cin>>pat_name[i];
			cout<<"\n Enter patient "<<i<<"age :";
			cin>>pat_age[i];
			cout<<"\nEnter patient  "<<i<<"gender";
			cin>>pat_gender[i];
			cout<<"\n enter patient "<<i<<"card number :";
			cin>>pat_cardno[i];
			cout<<"\n Enter patient"<<i<<"case :";
			cin>>pat_case[i];
			cout<<"\n Enter patient "<<i<<"date :";
			cin>>pat_date[i];
			cout<<"\n Enter patient "<<i<<"assigned physician :";
			cin>>ass_phy[i];
			cout<<endl;
		}
		break;

case 3:
	cout<<"\t\tprogram to edit physician or patient information \n";



case 4:
	cout<<"\tProgram to delete physician or patient information \n";
	cout<<"\t----------------------------------------------------"<<endl;
	char choose,delphy_name[12];
	int
	cout<<"Enter phy to delete physician information \n";
	cout<<"enter pat to delete patient information \n";
	if(choose==phy)
		cin>>del_name[10];
	for(i=0;i<n;i++)
	{
		if(strcmp(phy_name[1],delphy_name)==0)
			found=i;
			if(check==1)
			for(i=found;i<n;i++)
			{
			strcpy(id[found,id[found+1]);
			}
			else
			cout<<"\n not found !";
			break;



case 5:
	cout<<"\t program to list all available physicians \n";
	cout<<"\t Number "<<"\t name "<<"\t ID "<<"\t specification "<<"\t work exepriance \n";
	for(i=0;i<n;i++)
	{
		cout<<\t i+1<<"\t"<<phy_name[i]<<"\t"<<phy_id[i];
		cout<<"\t"<<phy_spec[i]<<"\t"<<phy_workex[i];
		cout<<endl;
	}
	break;
case 6:
	cout<<"\t\tprogram to list all registered patients \n";
	cout<<"\t number "<<"\t name "<<"\tage"<<"\t gender"<<"\t card number \n";
	cout<<"\t case\n"<<"\t date"<<"\t assigned physician";
	cout<<endl;
	for(j=0;j<m;j++)
	{
		cout<<\t i+1<<"\t"<<pat_name[i]<<"\t"<<pat_age[i]<<"\t"<<pat_gender[i];
		cout<<"\t"<<pat_cardno[i]<<"\t"<<pat_case[i]<<"\t"<<pat_date[i];
		cout<<"\t<<ass_phy[i]<<endl;
	}
	break;
case 7:
	cout<<"\t program to search for a patient \n";
	char search_patname[12];
	int check=0;
	int found;
	cin>>search_patname;
	for(i=0;i<n;i++)
	{
		if(strcmp(pat_name,search_patname)==0)
	}
	ckeck=1;
	found=i;
	if(ckeck=1);
	{
		cout<<pat_name[found];
		cout<<pat_age[found];
	}
	else
		cout<<"\n not found \n";
	break;
case 8:
	cout<<"\t program search for a physician \n";
	char search_phyname[12];
	int check;
	int found;
	cin>>search_phyname;
	for(j=0;j<m;j++)
	{
		if(strcmp(phy_name,searchphyname)==0)
	}
	ckeck=0;
	found=i;
	if(ckeck=1)
	{
		cout<<phy_name[found];
		cout<<phy_id[found];
	}
	else
		cout<<"\n not found\n";
	break;
case 9:
	cout<<"\tCongratulation you finished your program \n";
	break;
	}
	
while((ch>9)||(ch<1));

}
Nick Evan commented: 10+ posts and no code tags -3

Recommended Answers

All 4 Replies

If you have done your program like above, but not run & edit program, then run & edit program, then ask specific question.

And use code tags.

As soon as I looked at the code, the ugly void main was staring me in the face. Please fix it in your code, so I can rest easier.

I have tried it and the first case run but when I entered the name of the first physician the progrma ends with out asking me the name of the second physician.
In case 3. I do not know how can I edit the information

#include<iostream.h>
#include<string.h>

int main()
{
    int ch,n,phy_id[100],phy_workex[100];
    char phy_name[100],phy_spec[100];
    char pat_name[100],pat_gender[10],pat_case[50],ass_phy[12];
    int m,pat_age[4],pat_cardno[20],pat_date[4];
        do
        {
            cout<<"\t\t\t TASK SELECTION WINDOW \n";
            cout<<"\t\t\t ********************* \n";
            cout<<"\t\tWhat would you like to do ?\n";
            cout<<"\t\t Please enter the number you choice \n";
            cout<<"\t\t 1.Register a physician/s \n";
            cout<<"\t\t 2.Register a patient/s \n";
            cout<<"\t\t 3.Edit physician or patient information \n";
            cout<<"\t\t 4.Delete patient or physician information \n";
            cout<<"\t\t 5.List all available physicians \n";
            cout<<"\t\t 6.List all registered patients \n";
            cout<<"\t\t 7.Search for a patient \n";
            cout<<"\t\t 8 Search for a physician \n";
            cout<<"\t\t 9.Quit a program \n";
            cout<<endl;


cout<<"Please enter your selection !\n";
cin>>ch;



switch(ch)
{
case 1:
        cout<<"\t How many physician you want to register ?\n";
        cin>>n;
        cout<<"Enter name,id,specification and work experiance of "<<n<<"physicians"<<endl;
        cout<<"--------------------------------------------------------------"<<endl;
        for(int i=0;i<n;i++)
        {
            cout<<"\nEnter physician "<<i+1 <<" name :\n";
            cin>>phy_name[i];
            cout<<"Enter physician "<<i+1<<" id :\n";
            cin>>phy_id[i];
            cout<<"\nEnter physician "<<i+1  <<" specification :\n";
            cin>>phy_spec[i];
            cout<<"\n Enter physician "<<i+1 <<" work experiance :\n";
            cin>>phy_workex[i];
            cout<<endl;
        }
        break;

case 2:
        cout<<"\t How many patient you want to register ?\n";
        cin>>m;
        cout<<"Enter name,age,gender,card no,case,date and assigned physician of"<<m<<"patients"<<endl;
        cout<<"-------------------------------------------------------------------------"<<endl;
        for(int j=0;j<m;j++)
        {
            cout<<"\n Enter patient "<<j+1<<"name :";
            cin>>pat_name[j];
            cout<<"\n Enter patient "<<j+1<<"age :";
            cin>>pat_age[j];
            cout<<"\nEnter patient  "<<j+1<<"gender";
            cin>>pat_gender[j];
            cout<<"\n enter patient "<<j+1<<"card number :";
            cin>>pat_cardno[j];
            cout<<"\n Enter patient"<<j+1<<"case :";
            cin>>pat_case[j];
            cout<<"\n Enter patient "<<j+1<<"date :";
            cin>>pat_date[j];
            cout<<"\n Enter patient "<<j+1<<"assigned physician :";
            cin>>ass_phy[j];
            cout<<endl;
        }
        break;


case 3:
    cout<<"\t\tprogram to edit physician or patient information \n";



case 4:
    cout<<"\tProgram to delete physician or patient information \n";
    cout<<"\t----------------------------------------------------"<<endl;
    char choose,delphy_name[12],phy;
    int check,found;
    cout<<"Enter phy to delete physician information \n";
    cout<<"enter pat to delete patient information \n";
    if(choose==phy)
        cin>>delphy_name[10];
    for(i=0;i<n;i++)
    {
        if(strcmp(phy_name[1],delphy_name)==0)
            found=i;
            if(check==1)
            for(i=found;i<n;i++)
            {
            strcpy(phy_name[found],phy_name[found+1]);
            }
            else
            cout<<"\n not found !";
            break;



case 5:
    cout<<"\t program to list all available physicians \n";
    cout<<"\t Number "<<"\t name "<<"\t ID "<<"\t specification "<<"\t work exepriance \n";
    for(i=0;i<n;i++)
    {
        cout<<"\t i+1<<"\t"<<phy_name[i]<<"\t"<<phy_id[i];
        cout<<"\t"<<phy_spec[i]<<"\t"<<phy_workex[i];
        cout<<endl;
    }
    break;
    }

case 6:
    cout<<"\t\tprogram to list all registered patients \n";
    cout<<"\t number "<<"\t name "<<"\tage"<<"\t gender"<<"\t card number \n";
    cout<<"\t case\n"<<"\t date"<<"\t assigned physician";
    cout<<endl;
    for(j=0;j<m;j++)
    {
        cout<<\t i+1<<"\t"<<pat_name[i]<<"\t"<<pat_age[i]<<"\t"<<pat_gender[i];
        cout<<"\t"<<pat_cardno[i]<<"\t"<<pat_case[i]<<"\t"<<pat_date[i];
        cout<<"\t<<ass_phy[i]<<endl;
    }
    break;
case 7:
    cout<<"\t program to search for a patient \n";
    char search_patname[12];
    int check=0;
    int found;
    cin>>search_patname;
    for(i=0;i<n;i++)
    {
        if(strcmp(pat_name,search_patname)==0)
    }
    ckeck=1;
    found=i;
    if(ckeck=1);
    {
        cout<<pat_name[found];
        cout<<pat_age[found];
    }
    else
        cout<<"\n not found \n";
    break;
case 8:
    cout<<"\t program search for a physician \n";
    char search_phyname[12];
    int check;
    int found;
    cin>>search_phyname;
    for(j=0;j<m;j++)
    {
        if(strcmp(phy_name,searchphyname)==0)
    }
    ckeck=0;
    found=i;
    if(ckeck=1)
    {
        cout<<phy_name[found];
        cout<<phy_id[found];
    }
    else
        cout<<"\n not found\n";
    break;
case 9:
    cout<<"\tCongratulation you finished your program \n";
    break;
    }

    }
    }
while((ch>9)||(ch<1));
return 0;
}
commented: Warned about code tags, and now on 12 posts -1

You are still not using code tags, I expect your replies from now on will be of little help to you, read what I put carefully as it may be some of the last half decent advice you get before people just satrt saying your doing it wrong as it would suit your attitude better.

A) You are using void main, this is WRONG! It should be int main.
B) You are using old C headers, why when we are using C++ I don't know...
C) You are using cin and are completely unaware of the way it works with the input stream, I suggest you do some reading about it and clearing the input buffer, even better consider using getline() as it eliminates lots of problems. There is a sticky at the top of this C++ forum that explains about cin>> and clearning the input buffer and the problems this can cause and how not to do it. That is a VERY good starting point.

Please read the forum rules, rather than just virtually mimicing your original post with a post that is of next to no more help and continuing to violate forum rules.

Chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.