Question

In: Computer Science

C++ Download Lab10.cpp . In this file, the definition of the class personType has given. Think...

C++

Download Lab10.cpp . In this file, the definition of the class personType has given. Think of the personType as the base class.

Lab10.cpp is provided below:

#include <iostream>
#include <string>
using namespace std;
// Base class personType
class personType
{
public:
void print()const;
//Function to output the first name and last name
//in the form firstName lastName.
void setName(string first, string last);

string getFirstName()const;
string getLastName()const;
personType(string first = "", string last = "");
//Constructor
//Sets firstName and lastName according to the parameters.
//The default values of the parameters are null strings.
//Postcondition: firstName = first; lastName = last
private:
string firstName; //variable to store the first name
string lastName; //variable to store the last name
};

void personType::print() const
{
cout << "Person FirstName="<<firstName << " LastName=" << lastName<< endl;
}

void personType::setName(string first, string last)
{
firstName = first;
lastName = last;
}

string personType::getFirstName() const
{
return firstName;
}

string personType::getLastName() const
{
return lastName;
}

//constructor
personType::personType(string first, string last)

{
firstName = first;
lastName = last;
}
// --------------------Start your code from here

//--------------------driver program
int main()
{

personType person1("Lisa", "Regan");
doctorType doctor1("Sarah", "Conner", "Dentist");
patientType patient1("Sam", "Fire",200,100,1916);
billType b1;
b1.setDoctor(doctor1);
b1.setPatient(patient1);
b1.setCharge(250.66);
cout << "<personType> Printing...\n";
person1.print();
cout << endl;
cout << "<doctorType> Printing...\n";
doctor1.print();
cout << endl;
cout << "<patientType> Printing...\n";
patient1.print();
cout << endl;
cout << "<billType> Printing...\n";
b1.print();
cout << endl;
return 0;
}

Question:

● Derive the class doctorType, inherited from the class personType, with an additional class member variable member to store a doctor’s specialty(string type) Then, implement following class member function prototypes.
doctorType(string,string,string);//Firstname Lastname Specialty
doctorType();//Default constructor
void setSpecialty(string);//Set doctor specialty
string getSpecialty()const;// Get doctor specialty
void print()const;//Display doctor information the same as given output format

● Derive the class patientType, inherited from the class personType, with additional class
member variables to store a patient’s id , age , and dob (Date of birth)(All are integer ).
Then, implement following class member function prototypes.
patientType(string, string, int, int, int);//Firstname Lastname id age dob
patientType();Default constructor
void setId(int);//Set patient id
void setage(int);//Set patient age
void setDob(int);//Set patient DOB
int getId()const;//Get patient id
int getage()const;//Get patient
int getDob()const;//Get patient DOB
void print()const; //Display patient information the same as given output format

● Design a class billType, with class member variables to store a patient’s information
( patientType ), the patient’s doctor’s information ( doctorType ), and the hospital
charges( double ). Then, implement following class member function prototypes.
billType(doctorType &, patientType &); // Constructor
void setCharge(double);//Set hospital charges
double getCharge()const;//Get hospital charges
void print()const;//Display a bill information the same as given output format

Use the provided driver program to test your program. You should get the same output

Output:

<perspnType> Printing...

Person FirstName=Lisa LastName=Regan

<doctorType> Printing...

Doctor FirstName=Sarah LastName=Conner Specialty=Dentist

<patientType> Printing...

Patient FirstName=Sam LastName=Fire Id=200 Age=100 DOB=1916

<billType> Printing..

Patient FirstName=Sam LastName=Fire Id=200 Age=100 DOB=1916

Patient's doctor FirstName=Sarah LastName=Conner Specialty=Dentist

Hospital charge=250.66$

Press any key to continue...

Solutions

Expert Solution

#include <iostream>

#include <iomanip>

#include <string>

#include "Fields_HealthProfile.h"

using namespace std;

int main()

{

string a;

char b;

int c;

float e;

//-| Collecting Person's Name

cout << "Enter the person's First Name" << endl;

cin >> a;

set_Fname(a);

cout << "Enter the person's Last Name" << endl;

cin >> a;

set_Lname(a);

//-| Collecting Male or Female

cout << "Enter the person's Gender" << endl;

cin >> b;

set_gender(b);

//-| Collectiong Birth Information

cout << "What is the birth month (in form ex. 01) ?" << endl;

cin >> c;

set_bmonth(c);

cout << "What is the birth day (in form ex. 05) ?" << endl;

cin >> c;

set_bday(c);

cout << "What is the birth year (in form ex. 1992) ?" << endl;

cin >> c;

set_byear(c);

//-| Collecting Height and Weight

cout << "What is the Person's Height in inches?" << endl;

cin >> e;

set_height(e);

cout << "What is the Person's Weight in pounds?" << endl;

cin >> e;

set_weight(e);

//-| Calculating and Printing: Age, BMI, Max Heart Rate, and Target Heart Rate.

int age;

age = person_age();

float bodymass;

bodymass = body_mass();

int mheart;

int theart;

mheart = max_heartrate(age);

theart = targetheartrate(mheart);

cout << "The Person's Age is: " << age << " their BMI is: " << bodymass << " their Maximum Heart Rate is: " << mheart << " and their Target Heart Rate is: " << theart << '.' << endl;

return 0;

}


Related Solutions

This class should include .cpp file, .h file and driver.cpp (using the language c++)! Overview of...
This class should include .cpp file, .h file and driver.cpp (using the language c++)! Overview of complex Class The complex class presents the complex number X+Yi, where X and Y are real numbers and i^2 is -1. Typically, X is called a real part and Y is an imaginary part of the complex number. For instance, complex(4.0, 3.0) means 4.0+3.0i. The complex class you will design should have the following features. Constructor Only one constructor with default value for Real...
c++ Write the implementation (.cpp file) of the Counter class of the previous exercise. The full...
c++ Write the implementation (.cpp file) of the Counter class of the previous exercise. The full specification of the class is: A data member counter of type int. An data member named counterID of type int. A static int data member named nCounters which is initialized to 0. A constructor that takes an int argument and assigns its value to counter. It also adds one to the static variable nCounters and assigns the (new) value of nCounters to counterID. A...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
Write a C++ program that design a class definition to be put in a header file...
Write a C++ program that design a class definition to be put in a header file called fizzjazz.h A store sells online FizzJazz which are sound tones made by famous bands. For each FizzJazz, the store wants to keep track of the following attributes: * title - the name of the sound tone * band - Famous band name that created the tone * duration - this is in seconds and may be fractional: examples: 20.0, 34.5 Each attribute will...
answer in c++ First – take your Box02.cpp file and rename the file Box03.cpp Did you...
answer in c++ First – take your Box02.cpp file and rename the file Box03.cpp Did you ever wonder how an object gets instantiated (created)? What really happens when you coded Box b1; or Date d1; or Coord c1; I know you have lost sleep over this. So here is the answer………. When an object is created, a constructor is run that creates the data items, gets a copy of the methods, and may or may not initialize the data items....
C++ please Instructions Download and modify the Lab5.cpp program. Currently the program will read the contents...
C++ please Instructions Download and modify the Lab5.cpp program. Currently the program will read the contents of a file and display each line in the file to the screen. It will also display the line number followed by a colon. You will need to change the program so that it only display 24 lines from the file and waits for the user to press the enter key to continue. Do not use the system(“pause”) statement. Download Source Lab 5 File:...
Using C++ Create the UML, the header, the cpp, and the test file for an ArtWork...
Using C++ Create the UML, the header, the cpp, and the test file for an ArtWork class. The features of an ArtWork are: Artist name (e.g. Vincent vanGogh or Stan Getz) Medium (e.g. oil painting or music composition) Name of piece (e.g. Starry Night or Late night blues) Year (e.g. 1837 or 1958)
Part I – Understand a Given Class (die class) (40 pts) • Download the die class...
Part I – Understand a Given Class (die class) (40 pts) • Download the die class (attached as usingDieClass.cpp), save it as LabUseDieClassFirstName1_FirstName2.cpp • Add proper opening comments at the beginning of the program. The comments must include the description of all three parts of this lab. You may want to modify the comments after all parts are done to be sure that it is done properly. • Run the program and answer the following questions: o How many objects...
c++ ///////////////////////////////////////////////////////////////////////// need to be named Subsequences.h and pass test cpp file SubsequenceTester.cpp at the end...
c++ ///////////////////////////////////////////////////////////////////////// need to be named Subsequences.h and pass test cpp file SubsequenceTester.cpp at the end of this question. This assignment will help you solve a problem using recursion Description A subsequence is when all the letters of a word appear in the relative order of another word. Pin is a subsequence of Programming ace is a subsequence of abcde bad is NOT a subsequence abcde as the letters are not in order This assignment you will create a Subsequence...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT