Advertisement
Guest User

Untitled

a guest
Apr 14th, 2019
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. struct HealthProfile
  4. {
  5.  
  6. char firstName[10], lastName[10], gender[2];
  7.  
  8. int height, weight, day, month, year, current_year, tHR, maxHR, HR;
  9. };
  10.  
  11. void read(struct HealthProfile* s) {
  12.  
  13. printf("Please enter the patient's last name \n");
  14. scanf("%s", s->lastName);
  15. printf("Please enter the patient's first name \n");
  16. scanf("%s", s->firstName);
  17. printf("Please enter the patient's gender(M/F) \n");
  18. scanf("%s", s->gender);
  19. printf("Please enter the current year \n");
  20. scanf("%d", & s->current_year);
  21. printf("Please enter the patient's birthdate as mm/dd/yyyy \n");
  22. scanf("%d/%d/%d", & s->month, & s->day, & s->year);
  23. printf("Please enter the patient's height in inches \n");
  24. scanf("%d", & s->height);
  25. printf("Please enter the patient's weight in pounds \n");
  26. scanf("%d", & s->weight);
  27. printf("Please enter the patient's heart rate \n");
  28. scanf("%d", & s->HR);
  29. }
  30.  
  31. int Bmi(struct HealthProfile* s) {
  32. return ((703 * s->weight) / (s->height * s->height));
  33. }
  34.  
  35. int age(struct HealthProfile* s) {
  36. return (s->current_year - s->year);
  37. }
  38.  
  39. void heartRate(struct HealthProfile* s) {
  40. /* as no formula and parameters are given for calculating heart rate So defaults has been taken*/
  41.  
  42. int maxrate = 220;
  43. int heartrate = maxrate - age(s);
  44. int val = heartrate - s->HR;
  45.  
  46. float res1 = (val * 0.4);
  47. float res2 = (val * 0.6);
  48.  
  49. float targetmin = res1 + heartrate; // assuming HR means HeartRate
  50. float targetmax = res2 + heartrate;
  51.  
  52. printf("\nHeart beat low rate: %.1f - %.1f", targetmin, targetmax);
  53.  
  54. res1 = (val * 0.6);
  55. res2 = (val * 0.7);
  56.  
  57. targetmin = res1 + heartrate;
  58. targetmax = res2 + heartrate;
  59. printf("\nHeart beat medium rate: %.1f - %.1f", targetmin, targetmax);
  60.  
  61. res1 = (val * 0.7);
  62. res2 = (val * 0.85);
  63.  
  64. targetmin = res1 + heartrate;
  65. targetmax = res2 + heartrate;
  66. printf("\nHeart beat high rate: %.1f - %.1f", targetmin, targetmax);
  67.  
  68. }
  69.  
  70. void display(struct HealthProfile* s) {
  71. printf("The patient's name %s %s \n", s->firstName, s->lastName);
  72. printf("The patient's gender %s \n", s->gender);
  73. printf("The patient's birthdate %d/%d/%d \n", s->month, s->day, s->year);
  74. printf("The patient's height %d \n", s->height);
  75. printf("The patient's weight %d\n", s->weight);
  76. printf("The patient's age %d \n", age(s));
  77. printf("The patient's BMI %d \n", Bmi(s));
  78. heartRate(s);
  79. }
  80.  
  81.  
  82. int main()
  83. {
  84. struct HealthProfile* HP;
  85. read(HP);
  86. display(HP);
  87.  
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement