I am looking for some help writing a C program to calculate a users BMR (Basal M
ID: 3769671 • Letter: I
Question
I am looking for some help writing a C program to calculate a users BMR (Basal Metabolic Rate). I would like the user to enter their gender(1=m, 2=f), age, current weight in pounds, height in inches and how active they are
activity level (1 to 5)
Sedentary = Little or no exercise
Somewhat Active = Light exercise 1 - 3 days a week
Moderately Active = Moderate exercise or sports 3 - 5 days a week
Very Active = Hard exercise or sports 6 - 7 days a week
Extra Active = Very hard excersie
This is for calculating the BMR:
If you are a man, your BMR is equal to: 65 + (6.2 x weight in pounds) + (12.7 x height in inches) - (6.8 x age in years)
If you are a woman, your BMR is equal to: 655 + (4.3 x weight in pounds) + (4.3 x height in inches) - (4.7 x age in years)
After calculating their BMR I would like to also calculate their activity factor.
Activity Factor
sedentary (little or no exercise): C = BMR x 1.2
somewhat active (light exercise 1-3 days/wk): C = BMR x 1.375
moderately active (moderate exercise 3-5 days/wk): C = BMR x 1.55
very active (hard exercise 6-7 days/wk): C = BMR x 1.725
extra active (very hard exercise): C = BMR x 1.9
Explanation / Answer
#include <stdio.h>
int main()
{
int gender,level;
float age,weight,height,BMR,C;
printf("Answer these following questions ");
printf("Press 1 for Male Press 2 Female ");
scanf("%d",&gender);
printf("What is your age (in years)::");
scanf("%d",&age);
printf("Current weight in pounds? ");
scanf("%lf",&weight);
printf("Height in inches ");
scanf("%lf",&height);
printf("What is your activity level? ");
printf("1.Sedantary = Little or no exercise ");
printf("2.Somewhat active = Little exercise 1-3 days a week ");
printf("3.Moderately Active = Moderate exercise or sports 3-5 days a week ");
printf("4.Very Active = Hard exercise or sports 6-7 days a week ");
printf("5.Extra Active = Very hard exercise ");
printf("Which would you like to choose::");
scanf("%d",&level);
if(gender == 1)
BMR = 65 + (6.2*weight) + (12.7*height) - (6.8*age);
else if(gender == 2)
BMR = 655 + (4.3*weight) + (4.3*height) - (4.7*age);
else
printf("Gender entered wrong. ");
switch(level)
{
case 1: C = BMR*1.2;break;
case 2: C = BMR*1.375;break;
case 3: C = BMR*1.55;break;
case 4: C = BMR*1.725;break;
case 5: C = BMR*1.9;break;
}
printf("BMR is %lf ",BMR);
printf("Actvity Factor is %lf ",C);
return 1;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.