Answer to Question #324165 in C++ for Kassim

Question #324165

Q1. Design an application for hospital management system. For this, create the following classes

and members.

Person - name, date of birth, sex

Doctor - Specialization

Patient- Casenumber, Disease, date of admission, date of discharge, bill number.

Write function to input the data from the user and display data to the user.


1
Expert's answer
2022-04-05T13:17:55-0400
#include <iostream>
#include <string>
using namespace std;

class Person
{
	string name;
	string date_of_birth;
	char sex;
public:
	Person(){}
	void InputData()
	{
		cout << "\nPlease, enter a name of person: ";
		cin >> name;
		cout << "Please, enter date of birth of person: ";
		cin >> date_of_birth;
		cout << "Please, enter a sex of person [M/W]: ";
		cin >> sex;
	}
	void Display()
	{
		cout << "\nInfo about person:"
			<< "\nName: " << name
			<< "\nDate of birth: " << date_of_birth
			<< "\nSex: " << sex;
	}
};


class Doctor:public Person
{
	string special;
public:
	Doctor():Person(){}
	void InputDocData()
	{
		InputData();
		cout << "Please, enter a special of doctor: ";
		cin >> special;
	}
	void DisplayDoctor()
	{
		Display();
		cout << "\nDoctor`s specialization: " << special;
	}
};
 
class Patient:public Person
{
	int caseNum;
	string disease;
	string date_of_admis;
	string date_of_disch;
	int billNum;
public:
	Patient():Person(){}
	void InputPatData()
	{
		InputData();
		cout << "Please, enter a case number of person: ";
		cin >> caseNum;
		cout << "Please, enter a disease of person: ";
		cin >> disease;
		cout << "Please, enter date of adminsssion of person: ";
		cin >> date_of_admis;
		cout << "Please, enter date of discharge of person: ";
		cin >> date_of_disch;
		cout << "Please, enter bill number of person: ";
		cin >> billNum;
	}
	void DisplayPat()
	{
		Display();
		cout << "\nCase number: " << caseNum
			<< "\nDisease: " << disease
			<< "\nDate of admission: " << date_of_admis
			<< "\nDate of discharge: " << date_of_disch
			<< "\nBill number: " << billNum;
	}
};

int main()
{
	Doctor d;
	d.InputDocData();
	d.DisplayDoctor();
	Patient p;
	p.InputPatData();
	p.DisplayPat();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Kassim
05.04.22, 21:02

Thanks.Very helpful.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS