Question
1. Please write the following code in c++. Please also show all tht output. First review the code and submit the screen output for the
1. Please write the following code in c++. Please also show all tht output.
First review the code and submit the screen output for the attached CPP source code by creating six patient objects for the following people:
Obj_Patients.cppPreview the document
1) A 33-year-old woman, non-smoker with normal blood pressure who eats a high fat diet.
2) A 19-old-year man, non-smoker with high blood pressure who eats a high fat diet.
3) A 50-old-year woman, non-smoker with high blood pressure who eats a high fat diet.
4) A 27-year-old man, smoker with high blood pressure who eats a low fat diet.
5) A 43-year-old woman, smoker with high blood pressure who eats a high fat diet.
6) A 17-year-old woman, non-smoker with normal blood pressure who eats a high fat diet.
*/
#include
#include
using namespace std;
class Patient //ADT
{
private: string name;
int age;
int smoker, HBP, HFD;
int points;
public:
Patient();
Patient(string, int, int, int, int);
void calPoints();
void setPatient(string , int, int, int, int);
void dispPatient();
};
Patient::Patient(string n, int a, int s, int hbp, int hfd)
{
name = n;
age = a;
smoker = s;
HBP = hbp;
HFD = hfd;
}
Patient::Patient()
{
name = "";
age = smoker = HBP = HFD = 0;
}
void Patient::setPatient(string n, int a, int s, int hbp, int hfd)
{
name = n;
age = a;
smoker = s;
HBP = hbp;
HFD = hfd;
}
void Patient::calPoints()
{
if (age < 20)
points = 1;
else if (age < 30)
points = 2;
else
points = 3;
if (smoker == 1) points += 4;
if (HBP == 1) points += 2;
if (HFD == 1) points += 1;
}
void Patient::dispPatient()
{
cout << "Name: " << name << endl;
cout << "Points: " << points << endl;
}
int main()
{
//Add your c++ code
Patient me("James Shandeh", 21, 0, 0, 1);
me.calPoints();
me.dispPatient();
Patient you;
you.setPatient("Mike Smith", 23, 1,1,1);
you.calPoints();
you.dispPatient();
system("pause");
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started