I\'m looking for an answer for this code in C++ the ones I have found on here wi
ID: 3885481 • Letter: I
Question
I'm looking for an answer for this code in C++ the ones I have found on here will not output for me for some reason.
Your local hospital has asked you to develop a program that will manage health care records. Implement the following 2 classes and write a program that tests these classes:
Patient class has private data members firstName, lastName, patientID, billTotal.
Doctor class has private data members firstName, lastName, specialization.
For each class implement at least one constructor. The constructor should initialize at least one of the private data members. For each class implement accessor member functions for all private data members. For the Patient class, implement a mutator member function that sets the billTotal data member to an updated total if a charge has been made.
To test a class you would write a program that uses the constructor to construct an object of the class type and then calls all mutator member functions. Write a program that tests your Patient and Doctor classes. You must thoroughly comment your code by providing a comment for each line of code. Apply troubleshooting and testing strategies to ensure your code compiles, runs, and provides accurate results.
Explanation / Answer
#include<iostream>
#include<string>
using namespace std;
class Patient {
private:
string patientID;
string firstName;
string lastName;
double billTotal;
public:
Patient(string a){
firstName = a;
}
void setFirstName(string a){
firstName = a;
}
void setLastName(string a){
lastName = a;
}
void setBillTotal(double a){
billTotal = a;
}
void setPatientID(string a){
patientID = a;
}
string getFirstName(){
return firstName;
}
string getLastName(){
return lastName;
}
double getBillTotal(){
return billTotal;
}
string getPatientID(){
return patientID;
}
};
class Doctor {
private:
string firstName;
string lastName;
string specialization;
public:
Doctor(string a){
firstName = a;
}
void setFirstName(string a){
firstName = a;
}
void setLastName(string a){
lastName = a;
}
void setSpecialization(string a){
specialization = a;
}
string getFirstName(){
return firstName;
}
string getLastName(){
return lastName;
}
string getSpecialization(){
return specialization;
}
};
int main(){
Patient p("Marry");
Doctor d("John");
d.setSpecialization("Surgery");
d.setLastName("Walker");
p.setLastName("Jones");
p.setBillTotal(45.67);
p.setPatientID("12345");
cout << "Doctor" << endl;
cout << d.getFirstName() << " " << d.getLastName() << " " << d.getSpecialization() << endl;
cout << "Patient" << endl;
cout << p.getPatientID() << " " << p.getFirstName() << " " << p.getLastName() << " " << p.getBillTotal() << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.