SlideShare a Scribd company logo
In C++:
15.4:
=====
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).

More Related Content

PDF
Design various classes and write a program to computerize the billing.pdf
PPT
Lecture20
PDF
Implement in C++Create a class named Doctor that has three member .pdf
PDF
OOP_EXPLAINED_example_of_cod_and_explainations.pdf
PDF
struct procedure {    Date dateOfProcedure;    int procedureID.pdf
PPT
Lecture21
DOCX
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
PPT
C++lecture9
Design various classes and write a program to computerize the billing.pdf
Lecture20
Implement in C++Create a class named Doctor that has three member .pdf
OOP_EXPLAINED_example_of_cod_and_explainations.pdf
struct procedure {    Date dateOfProcedure;    int procedureID.pdf
Lecture21
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
C++lecture9

Similar to In C++ 154 Define a base class called Person The .pdf (20)

PPT
w10 (1).ppt
DOC
Pads lab manual final
PDF
Question I need help with c++ Simple Classes Assigment. i get this .pdf
DOCX
OOP program questions with answers
PPT
Lecture19
PPT
Class ‘increment’
PDF
A Language Independent Task Engine for Incremental Name and Type Analysis - S...
PDF
Ch 4
PDF
C++ prgms 3rd unit
PDF
C++ normal assignments by maharshi_jd.pdf
DOCX
main-cpp file #include -iostream- #include -vector- #include -Date-h.docx
PPT
Classes and Inheritance
DOCX
Brinkley – Over HereChanges during WWII led to an .docx
PDF
Below is my program, I just have some issues when I want to check ou.pdf
PPTX
CPP Homework Help
PDF
PDF
EEE 3rd year oops cat 3 ans
PDF
A Task Engine for Name and Type Analysis
PDF
Define a class named Doctor whose objects are records for clinic’s d.pdf
PDF
OOPs theory about its concepts and properties.
w10 (1).ppt
Pads lab manual final
Question I need help with c++ Simple Classes Assigment. i get this .pdf
OOP program questions with answers
Lecture19
Class ‘increment’
A Language Independent Task Engine for Incremental Name and Type Analysis - S...
Ch 4
C++ prgms 3rd unit
C++ normal assignments by maharshi_jd.pdf
main-cpp file #include -iostream- #include -vector- #include -Date-h.docx
Classes and Inheritance
Brinkley – Over HereChanges during WWII led to an .docx
Below is my program, I just have some issues when I want to check ou.pdf
CPP Homework Help
EEE 3rd year oops cat 3 ans
A Task Engine for Name and Type Analysis
Define a class named Doctor whose objects are records for clinic’s d.pdf
OOPs theory about its concepts and properties.
Ad

More from aayushmaany2k14 (20)

PDF
7 In pea plants round R is dominant to wrinkled r A h.pdf
PDF
7 In cats some are black some are orange and some are ca.pdf
PDF
7 You have just discovered a new fungal species from Yellow.pdf
PDF
7 Write the MIPS code to implement the for loop below Use .pdf
PDF
7 Given the diagram above describe the order of events in .pdf
PDF
7 Ontario Resources a natural energy supplier borrowed 8.pdf
PDF
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf
PDF
7 Essay What is the difference between efficiency and equ.pdf
PDF
7 What is most true about the following B2B promotional too.pdf
PDF
7 What do foxes and birds have in common a They are both .pdf
PDF
7 Using terms from the key on the right correctly identify.pdf
PDF
7 Using node 1 as the root perform a BFS for node 6 Detai.pdf
PDF
8 The residents of Elk Meadows and Valley View are experien.pdf
PDF
8 What would be the most possible interaction between the s.pdf
PDF
8 A unique structure in vertebrate embryos is the somite S.pdf
PDF
7 Kate has a utility function Uxy4xpath dM95702c.pdf
PDF
8 Protein synthesis begins when in the nucleus of each cell.pdf
PDF
729 David is going to purchase two stocks to form the initi.pdf
PDF
8 IPOsinitial public offerings of stockcreate billions of.pdf
PDF
8 Agreement and disagreement among economists Suppose that .pdf
7 In pea plants round R is dominant to wrinkled r A h.pdf
7 In cats some are black some are orange and some are ca.pdf
7 You have just discovered a new fungal species from Yellow.pdf
7 Write the MIPS code to implement the for loop below Use .pdf
7 Given the diagram above describe the order of events in .pdf
7 Ontario Resources a natural energy supplier borrowed 8.pdf
7 Let XiiZ+1i2path dM263681c0701839752119c34.pdf
7 Essay What is the difference between efficiency and equ.pdf
7 What is most true about the following B2B promotional too.pdf
7 What do foxes and birds have in common a They are both .pdf
7 Using terms from the key on the right correctly identify.pdf
7 Using node 1 as the root perform a BFS for node 6 Detai.pdf
8 The residents of Elk Meadows and Valley View are experien.pdf
8 What would be the most possible interaction between the s.pdf
8 A unique structure in vertebrate embryos is the somite S.pdf
7 Kate has a utility function Uxy4xpath dM95702c.pdf
8 Protein synthesis begins when in the nucleus of each cell.pdf
729 David is going to purchase two stocks to form the initi.pdf
8 IPOsinitial public offerings of stockcreate billions of.pdf
8 Agreement and disagreement among economists Suppose that .pdf
Ad

Recently uploaded (20)

PPTX
Cell Types and Its function , kingdom of life
PDF
Computing-Curriculum for Schools in Ghana
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
master seminar digital applications in india
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Lesson notes of climatology university.
PDF
Classroom Observation Tools for Teachers
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Yogi Goddess Pres Conference Studio Updates
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Types and Its function , kingdom of life
Computing-Curriculum for Schools in Ghana
O7-L3 Supply Chain Operations - ICLT Program
master seminar digital applications in india
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Microbial diseases, their pathogenesis and prophylaxis
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Complications of Minimal Access Surgery at WLH
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
202450812 BayCHI UCSC-SV 20250812 v17.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
GDM (1) (1).pptx small presentation for students
Supply Chain Operations Speaking Notes -ICLT Program
Lesson notes of climatology university.
Classroom Observation Tools for Teachers
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Yogi Goddess Pres Conference Studio Updates
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

In C++ 154 Define a base class called Person The .pdf

  • 1. In C++: 15.4: ===== 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
  • 2. 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).