Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A health care issue that has been in the news lately is the computerization of h

ID: 3914519 • Letter: A

Question

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 history 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. In this exercise, you will design a “starter” HealthProfilestructure for a person. The structure’s members should include the person’s first name, last name, gender, height (in inches) and weight (in pounds). Your program will create an array of HealthProfile structure for up to 30 people. The user will enter the information and store them into the array of HealthProfile structure. Your program will display the information in a tubular format with values aligned properly. Then, write a function to calculate the average of the weight. struct healthProfile { char first[15]; char last[15]; char gender[1]; int height; // in inches int weight; // in pounds };

Explanation / Answer

#include <iostream>
using namespace std;

double avgWeight(struct healthProfile[],int);// function to calculate average weight
struct healthProfile
{
char first[15];
char last[15];
char gender[1];
int height; // in inches
int weight; // in pounds
};
int main() {

struct healthProfile hp[30];// array of 30 structures

int n;

cout<<"Enter the number of patients : ";
cin>>n;

cout<<" Enter the health profiles for "<<n<<" patients : ";

for(int i=0;i<n;i++)
{
  cout<<" Enter the first name of patient : ";
  cin>>hp[i].first;
  cout<<" Enter the last name of patient : ";
  cin>>hp[i].last;
  cout<<" Enter the gender of patient : ";
  cin>>hp[i].gender;
  cout<<" Enter the height of patient : ";
  cin>>hp[i].height;
  cout<<" Enter the weight of patient : ";
  cin>>hp[i].weight;
}
cout<<endl;
cout<<" Name Gender Height Weight"<<endl;
for(int i=0;i<n;i++)
{
  cout<<hp[i].first<<" "<<hp[i].last<<" "<<hp[i].gender<<" "<<hp[i].height<<" "<<hp[i].weight<<endl;
  
}

cout<<" Average weight : "<<avgWeight(hp,n);

return 0;
}

double avgWeight(struct healthProfile hp[],int n)
{
double avgWt = 0;

for(int i=0;i<n;i++)
{
  avgWt = avgWt + hp[i].weight;// average weight
}

return avgWt/n;
}

Output:

Enter the number of patients :3
Enter the health profiles for 3 patients :
Enter the first name of patient :Mathew
Enter the last name of patient :James
Enter the gender of patient :M
Enter the height of patient :5
Enter the weight of patient :89
Enter the first name of patient :Candy
Enter the last name of patient :Thompson
Enter the gender of patient :F
Enter the height of patient :4
Enter the weight of patient :67
Enter the first name of patient :Allen
Enter the last name of patient :James
Enter the gender of patient :M
Enter the height of patient :6
Enter the weight of patient :107

Name Gender Height Weight
Mathew James M 5 89
Candy Thompson F 4 67
Allen James M 6 107

Average weight : 87.6667

Do ask if any doubt. Please upvote.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote