Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct HealthProfile
- {
- char firstName[10], lastName[10], gender[2];
- int height, weight, day, month, year, current_year, tHR, maxHR, HR;
- };
- void read(struct HealthProfile* s) {
- printf("Please enter the patient's last name \n");
- scanf("%s", s->lastName);
- printf("Please enter the patient's first name \n");
- scanf("%s", s->firstName);
- printf("Please enter the patient's gender(M/F) \n");
- scanf("%s", s->gender);
- printf("Please enter the current year \n");
- scanf("%d", & s->current_year);
- printf("Please enter the patient's birthdate as mm/dd/yyyy \n");
- scanf("%d/%d/%d", & s->month, & s->day, & s->year);
- printf("Please enter the patient's height in inches \n");
- scanf("%d", & s->height);
- printf("Please enter the patient's weight in pounds \n");
- scanf("%d", & s->weight);
- printf("Please enter the patient's heart rate \n");
- scanf("%d", & s->HR);
- }
- int Bmi(struct HealthProfile* s) {
- return ((703 * s->weight) / (s->height * s->height));
- }
- int age(struct HealthProfile* s) {
- return (s->current_year - s->year);
- }
- void heartRate(struct HealthProfile* s) {
- /* as no formula and parameters are given for calculating heart rate So defaults has been taken*/
- int maxrate = 220;
- int heartrate = maxrate - age(s);
- int val = heartrate - s->HR;
- float res1 = (val * 0.4);
- float res2 = (val * 0.6);
- float targetmin = res1 + heartrate; // assuming HR means HeartRate
- float targetmax = res2 + heartrate;
- printf("\nHeart beat low rate: %.1f - %.1f", targetmin, targetmax);
- res1 = (val * 0.6);
- res2 = (val * 0.7);
- targetmin = res1 + heartrate;
- targetmax = res2 + heartrate;
- printf("\nHeart beat medium rate: %.1f - %.1f", targetmin, targetmax);
- res1 = (val * 0.7);
- res2 = (val * 0.85);
- targetmin = res1 + heartrate;
- targetmax = res2 + heartrate;
- printf("\nHeart beat high rate: %.1f - %.1f", targetmin, targetmax);
- }
- void display(struct HealthProfile* s) {
- printf("The patient's name %s %s \n", s->firstName, s->lastName);
- printf("The patient's gender %s \n", s->gender);
- printf("The patient's birthdate %d/%d/%d \n", s->month, s->day, s->year);
- printf("The patient's height %d \n", s->height);
- printf("The patient's weight %d\n", s->weight);
- printf("The patient's age %d \n", age(s));
- printf("The patient's BMI %d \n", Bmi(s));
- heartRate(s);
- }
- int main()
- {
- struct HealthProfile* HP;
- read(HP);
- display(HP);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement