Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Define a base class called Person. The class should have two data members to hold the first name and last name of a person,

C++

Define a base class called Person. The class should have two data members

to hold the first name and last name of a person, both of type string. The

Person class will have a default constructor to initialize both data members to empty strings, a constructor to accept two string parameters and use them to initialize the first and last name, and a copy constructor. Also include appropriate accessor and mutator member functions. Overload the operators == and != such that two objects of class Person are considered equal if and only if both first and last names are equal. Also overload operators >>, <<, and =. Define a class called Doctor derived from the Person class. The class should have a data member to hold the doctor's hourly rate (of type double), a default constructor to initialize the rate to 0, and a constructor that takes a double and a reference to an object of type Person and initializes the data members to their appropriate values. Also include an accessor and mutator member functions for the doctor's hourly rate. In Doctor class, redefine the operator = such that it not only copies the first and last name, but also copies the hourly rate. Define another class called Patient derived from the Person class. This class should have a data member to hold the patient's primary physician (of class Doctor). Include a default constructor that would call the default constructors of class Doctor and Person to initialize the object; also include a constructor that accepts a reference to an object of class Doctor and Person and initializes the Patient object's data members to their respective values. Add accessor and mutator member functions to access or set the primary physician. Finally, define a class called Billing that would hold information about medical bills. This class should have the following data members: an object of type Doctor to hold the doctor to whom the money is paid, an object of type Patient to hold the patient who pays the money, and a variable of type double to hold the amount due. The Billing class will have a default constructor that initializes amount due to 0.0 and calls the default constructors for Patient and Doctor objects and a constructor that accepts references to Doctor and Patient objects and the amount of hours (type int). The latter constructor will calculate the amount due in the following fashion: * if the doctor involved in the bill is the patient's primary physician, then the amount due is hours multiplied by the doctor's hourly rate; * if the doctor involved is not the patient's primary physician, then the amount due is hours times doctor's hourly rate times 1.25. Write a main function that would prompt the user to enter the patient's name, their primary physician's name and rate, another doctor's name and rate, and the amount of hours spent in the doctor's office. Then the program will calculate and output the amount patient owes for doctor's services. Note: two doctors are considered the same if and only if their names match (i.e. you can assume no doctors with the same name and different rates exist).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago