Assigment #2 Q#8
A health care issue that has been in the news lately is the computerization of health records. This possibility is being approached cautiously because of sensitive privacy and security concerns, among others. Computerizing health records could make it easier for patients to share their health profiles and histories among their various health care professionals. This could improve the quality of health care, help avoid drug conflicts and erroneous drug prescriptions, reduce costs and in emergencies could save lives. Design a “starter” HealthProfile structure for a person. The structure’s members should include the person’s first name, last name, gender, date of birth (consisting of separate attributes for the month, day and year of birth), height (in inches) and weight (in pounds). Your program should have a function that receives this data and uses it to set the members of a HealthProfile variable. The program also should include functions that calculate and return the user’s age in years, maximum heart rate and targetheart-rate range
The program should prompt for the person’s information, create a HealthProfile variable for that person and display the information from that variable—including the person’s first name, last name, gender, date of birth, height and weight—then it should calculate and display the person’s
age in years, BMI, maximum heart rate and target-heart-rate range. It should also display the “BMI values” chart.
Hints:
The program should prompt for the person’s information, create a HealthProfile variable for that person and display the information from that variable—including the person’s first name, last name, gender, date of birth, height and weight—then it should calculate and display the person’s
age in years, BMI, maximum heart rate and target-heart-rate range. It should also display the “BMI values” chart.
Hints:
- According to the American Heart Association (AHA)
(www.americanheart.org/presenter.jhtml?identifier=4736), the formula for calculating
(www.americanheart.org/presenter.jhtml?identifier=4736), the formula for calculating
your maximum heart rate in beats per minute is 220 minus your age in years. Your target heart rate is a range that is 50–85% of your maximum heart rate. [Note: These formulas are estimates provided by the AHA. Maximum and target heart rates may vary based on the health, fitness and gender of the individual. Always consult a physician or qualified health care professional before beginning or modifying an exercise program.], and body mass index).
The formulas for calculating BMI are:
BMI = Weight In Kg’s/(Height In Meters)^2
The formulas for calculating BMI are:
BMI = Weight In Kg’s/(Height In Meters)^2
or
BMI = (Weight in pounds x 703)/( Height in Inches)^2
#include <iostream>
#include <string>
using namespace
std;
struct birthday{ //Attributes
of birthday
int month;
int day;
int year;
};
struct H_record{ //Struct
to store the record of a patient
string F_name;
string L_name;
string Gender;
float height;
float weight;
birthday br;
};
void
getData(H_record &); //Function
that takes the data from the user
int
ageInYears(int); //Function
that Calculates the age years
void
heartRate(H_record, int &, int &, int &, float &, int); //Function
to calculate the Max Heart rate
void print(H_record, int, int, int, int, float); //Function
to print the record
void
BMI_Chart(); //print the BMI values Chart
int main()
{
int age,
M_h, T_h1, T_h2;
float BMI;
H_record p1; //creating
instance
getData(p1);
age =
ageInYears(p1.br.year);
heartRate(p1,
M_h, T_h1, T_h2, BMI, age); //calling of the function to calculateM
print(p1, age,
M_h, T_h1, T_h2, BMI);
BMI_Chart();
system("pause");
return 0;
}
void
getData(H_record &p) //function
that takes record from the user
{
char s;
cout << "****HEALTH PROFILE****" << endl;
cout << "Enter your first name :";
getline(cin, p.F_name);
cout << "Enter your Last name :";
getline(cin, p.L_name);
cout << "Enter your Date of Birth (d /m /y)
:";
cin >> p.br.day
>> s >> p.br.month >> s >> p.br.year;
if ((p.br.day
<0 || p.br.day >31) && (p.br.month
<0 || p.br.month >12))
{
cout
<< "Invalid Date of Birth
Entered" << endl << "Again Enter your Date of Birth (d
/m /y) :";
cin
>> p.br.day >> s >> p.br.month
>> s >> p.br.year;
}
cout << "Enter your Height (Inches) :";
cin >> p.height;
cout << "Enter your Weight (Pounds) :";
cin >> p.weight;
}
int
ageInYears(int y) //function
that calculates the age in years
{
int c_y,
age;
cout << "Enter the current year :";
cin >>
c_y;
age = (c_y - y);
return age;
}
void
heartRate(H_record p, int & M, int & T1, int & T2, float & bmi, int ag)
{
M = 220 -
ag; //calculates
the Maximum heart rate
T1 = M*0.50; //calculate the targeted heart rate w.r.t 50%
T2 = M*0.85; //calculate the targeted heart rate w.r.t 85%
bmi = ((p.weight)
* 703) / ((p.height)*(p.height)); //calculatesthe
BMI
}
void print(H_record p, int age, int max, int t1, int t2, float bmi) //printing
the record of a patient
{
cout <<
endl << "First Name :" << p.F_name << endl;
cout << "Last Name :" << p.L_name << endl;
cout << "Age :" << age << endl;
cout << "Weight :" << p.weight << endl;
cout << "Height :" << p.height << endl;
cout << "Date :" << p.br.day << "/"
<< p.br.day << "/" << p.br.year << endl;
cout << "BMI :" << bmi << endl;
cout << " Maximum heart
rate :" << max
<< endl;
cout << "Target-heart-rate range :" << t1 << "
to " << t2
<< endl;
}
void
BMI_Chart() //Function to print BMIVlues
Chart
{
cout <<
endl << "**************************************" << endl;
cout << "BMI Values" << endl;
cout << "Under Weight : " << "less
than 18.5" << endl;
cout << "Normal : " << "between
18.5 and 24.9" << endl;
cout << "Overweight : " << "between
25 and 29.9" << endl;
cout << "Obese : " << "30
or greater" << endl;
cout << "**************************************" << endl;
No comments:
Post a Comment