Using C++. 4. Patient Charges Wri te a class named Patient that has member varia
ID: 3735815 • Letter: U
Question
Using C++.
4. Patient Charges Wri te a class named Patient that has member variables for the following data: . First name, middle name, last name . Address, city, state, and ZIP code . Phone number Name and phone number of emergency contact The Patient class should have a constructor that accepts an argument for each menm ber variable. The Patient class should also have accessor and mutator functions for each member variable Next, write a class named Procedure that represents a medical procedure that has been performed on a patient. The Procedure class should have member variables for the following data: . Name of the procedure . Date of the procedure . Name of the practitioner who performed the procedure . Charges for the procedure The Procedure class should have a constructor that accepts an argument for each member variable. The Procedure class should also have accessor and mutator func- tions for each member variable. Next, write a program that creates an instance of the Patient class, initialized with sample data. Then, create three instances of the Procedure class, initialized with the following data: Procedure #3: Procedure #2: Procedure name: X-ray Date: Today's date Date: Today's date Practitioner: Dr. Jamison Practitioner: Dr. Smith Charge: 500.00 Procedure #1: Procedure name: Blood test Procedure name: Physical Exam Date: Today's date Practitioner: Dr. Irvine Charge: 200.00 Charge: 250.00 The program should display the patient's information, information about all three of the procedures, and the total charges of the three procedures.Explanation / Answer
// Patient.h
#include <string>
class Patient
{
private:
std::string m_firstName;
std::string m_middleName;
std::string m_lastName;
std::string m_address;
std::string m_city;
std::string m_state;
int m_zipCode;
int m_phoneNumber;
std::string m_nameOFEmergencyContact;
int m_phoneNoOFEmergencyContact;
public:
//Constructor
Patient(std::string firstName, std::string middleName, std::string lastName, std::string address,
std::string city, std::string state, int zipCode, int phoneNumber, std::string nameOFEmergencyContact,
int phoneNoOFEmergencyContact);
//mutators
void SetFirstName(std::string &firstName);
void SetMiddleName(std::string &middleName);
void SetLastName(std::string &lastName);
void SetAddress(std::string &address);
void SetCity(std::string &city);
void SetState(std::string &state);
void SetZipCode(int &zipCode);
void SetPhoneNumber(int &phoneNumber);
void SetNameOFEmergencyContact(std::string &nameOFEmergencyContact);
void SetPhoneNoOFEmergencyContact(int &phoneNoOFEmergencyContact);
//accessors
std::string GetFirstName() const;
std::string GetMiddleName() const;
std::string GetLastName() const;
std::string GetAddress() const;
std::string GetCity() const;
std::string GetState() const;
int GetZipCode() const;
int GetPhoneNumber() const;
std::string GetNameOFEmergencyContact() const;
int GetPhoneNoOFEmergencyContact() const;
};
// Patient.cpp
#include "Patient.h"
Patient::Patient(std::string firstName, std::string middleName, std::string lastName, std::string address,
std::string city, std::string state, int zipCode, int phoneNumber, std::string nameOFEmergencyContact,
int phoneNoOFEmergencyContact)
{
m_firstName = firstName;
m_middleName = middleName;
m_lastName = lastName;
m_address = address;
m_city = city;
m_state = state;
m_zipCode = zipCode;
m_phoneNumber = phoneNumber;
m_nameOFEmergencyContact = nameOFEmergencyContact;
m_phoneNoOFEmergencyContact = phoneNoOFEmergencyContact;
}
void Patient::SetFirstName(std::string &firstName)
{
m_firstName = firstName;
}
void Patient::SetMiddleName(std::string &middleName)
{
m_middleName = middleName;
}
void Patient::SetLastName(std::string &lastName)
{
m_lastName = lastName;
}
void Patient::SetAddress(std::string &address)
{
m_address = address;
}
void Patient::SetCity(std::string &city)
{
m_city = city;
}
void Patient::SetState(std::string &state)
{
m_state = state;
}
void Patient::SetZipCode(int &zipCode)
{
m_zipCode = zipCode;
}
void Patient::SetPhoneNumber(int &phoneNumber)
{
m_phoneNumber = phoneNumber;
}
void Patient::SetNameOFEmergencyContact(std::string &nameOFEmergencyContact)
{
m_nameOFEmergencyContact = nameOFEmergencyContact;
}
void Patient::SetPhoneNoOFEmergencyContact(int &phoneNoOFEmergencyContact)
{
m_phoneNoOFEmergencyContact = phoneNoOFEmergencyContact;
}
std::string Patient::GetFirstName() const
{
return m_firstName;
}
std::string Patient::GetMiddleName() const
{
return m_middleName;
}
std::string Patient::GetLastName() const
{
return m_lastName;
}
std::string Patient::GetAddress() const
{
return m_address;
}
std::string Patient::GetState() const
{
return m_state;
}
std::string Patient::GetCity() const
{
return m_city;
}
int Patient::GetZipCode() const
{
return m_zipCode;
}
int Patient::GetPhoneNumber() const
{
return m_phoneNumber;
}
std::string Patient::GetNameOFEmergencyContact() const
{
return m_nameOFEmergencyContact;
}
int Patient::GetPhoneNoOFEmergencyContact() const
{
return m_phoneNoOFEmergencyContact;
}
// Procedure.h
#include <string>
class Procedure
{
private:
std::string m_name;
std::string m_date;
std::string m_nameOFPractitioner;
float m_charges;
public:
Procedure();
Procedure(std::string name, std::string date, std::string nameOFPractitioner, float charges);
void SetName(std::string &name);
void SetDate(std::string &date);
void SetNameOFPractitioner(std::string &nameOFPractitioner);
void SetCharge(float &charges);
std::string GetName() const;
std::string GetDate() const;
std::string GetNameOFPractitioner() const;
float GetCharges() const;
};
// Procedure.cpp
#include "Procedure.h"
Procedure::Procedure()
{
}
Procedure::Procedure(std::string name, std::string date, std::string nameOFPractitioner, float charges)
{
m_name = name;
m_date = date;
m_nameOFPractitioner = nameOFPractitioner;
m_charges = charges;
}
void Procedure::SetName(std::string &name)
{
m_name = name;
}
void Procedure::SetDate(std::string &date)
{
m_date = date;
}
void Procedure::SetNameOFPractitioner(std::string &nameOFPractitioner)
{
m_nameOFPractitioner = nameOFPractitioner;
}
void Procedure::SetCharge(float &charges)
{
m_charges = charges;
}
std::string Procedure::GetName() const
{
return m_name;
}
std::string Procedure::GetDate() const
{
return m_date;
}
std::string Procedure::GetNameOFPractitioner() const
{
return m_nameOFPractitioner;
}
float Procedure::GetCharges() const
{
return m_charges;
}
//Main.cpp
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <string>
#include "Patient.h"
#include "Procedure.h"
using namespace std;
int main()
{
string firstName;
cout<<"Enter the Patient First Name"<<endl;
cin>>firstName;
string middleName;
cout<<"Enter the Patient Middle Name"<<endl;
cin>>middleName;
string lastName;
cout<<"Enter the Patient Last Name"<<endl;
cin>>lastName;
string address;
cout<<"Enter the Patient Address"<<endl;
cin>>address;
string city;
cout<<"Enter the Patient City"<<endl;
cin>>city;
string state;
cout<<"Enter the Patient State"<<endl;
cin>>state;
int zipcode;
cout<<"Enter the Patient Zipcode";
cin>>zipcode;
int phoneNumber;
cout<<"Enter the Patient PhoneNumber";
cin>>phoneNumber;
string nameOFEmergencyContact;
cout<<"Enter the Patient Name OF EmergencyContact"<<endl;
cin>>state;
int phoneNumberOFEmergencyContact;
cout<<"Enter the Patient Phone OF EmergencyContact"<<endl;
cin>>phoneNumberOFEmergencyContact;
Patient patient(firstName,middleName,lastName,address,city,state,zipcode,phoneNumber,nameOFEmergencyContact,
phoneNumberOFEmergencyContact);
Procedure pro1("Physical Exam","Today's date","Dr. Irvine",250.00);
Procedure pro2("X=ray","Today's date","Dr. Jamison",500.00);
Procedure pro3("Blood test","Today's date","Dr. Smith",200.00);
Procedure proArray[3];
proArray[0] = pro1;
proArray[1] = pro2;
proArray[2] = pro3;
cout<< "=========================================================="<<endl;
cout<< "Patient Name = "<<patient.GetFirstName()<<" "<<patient.GetMiddleName()<<" "<<patient.GetLastName()<<endl;
cout<< "Patient Address = "<<patient.GetAddress()<<" "<<patient.GetCity()<<" "<<patient.GetState()<<" "<<
patient.GetZipCode()<<endl;
cout<< "Patient Name Of EmergencyContact "<<patient.GetNameOFEmergencyContact()<<endl;
cout<< "Patient phoneNumberOFEmergencyContact Of EmergencyContact "<<patient.GetPhoneNoOFEmergencyContact()<<endl;
int i = 0;
float chargesSum = 0;
while(i<3)
{
cout<<"Procedure "<<i<<endl;
cout<< "Procedure Name = "<<proArray[i].GetName()<<endl;
cout<< "Procedure Date = "<<proArray[i].GetDate()<<endl;
cout<< "Procedure Name OF Practitioner = "<<proArray[i].GetNameOFPractitioner()<<endl;
cout<< "Procedure Charges = "<<proArray[i].GetCharges()<<endl;
chargesSum = chargesSum+proArray[i].GetCharges();
i++;
}
cout<<"Total charges = "<< chargesSum<<endl;
return 0;
}
//PLEASE PROViDE FEEDBACK THUMBS UP
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.