A health care issue that has been in the news lately is the computerization of h
ID: 3910497 • 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
If you have any doubts, please give me comment...
#include <stdio.h>
struct healthProfile {
char first[15];
char last[15];
char gender[1];
int height; // in inches
int weight; // in pounds
};
double calcAvgWeight(struct healthProfile profiles[], int n);
int main(){
struct healthProfile profiles[30];
int n, i;
printf("How many profiles would you like to add(max 30): ");
scanf("%d", &n);
for(i=0; i<n; i++){
printf("Profile %d: ", i+1);
printf("First Name: ");
scanf("%s", profiles[i].first);
printf("Last Name: ");
scanf("%s", profiles[i].last);
printf("Gender: ");
scanf("%c", &profiles[i].gender[0]);
printf("height: ");
scanf("%d", &profiles[i].height);
printf("weight: ");
scanf("%d", &profiles[i].weight);
}
printf("%-15s %-15s %-6s %-10s %-10s ", "Firstname", "Lastname", "gender", "height", "weight");
for(i=0; i<n; i++){
printf("%-15s %-15s %-6c %-10d %-10d ", profiles[i].first, profiles[i].last, profiles[i].gender[0], profiles[i].height, profiles[i].weight);
}
printf("Average weight: %.2lf", calcAvgWeight(profiles, n));
return 0;
}
double calcAvgWeight(struct healthProfile profiles[], int n){
double avg = 0.0;
int i;
for(i=0; i<n; i++){
avg += profiles[i].weight;
}
avg /= n;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.