One measurement of a person\'s fitness is their Body Mass Index. The United Stat
ID: 3666655 • Letter: O
Question
One measurement of a person's fitness is their Body Mass Index. The United States Center for Disease Control uses this to classify people as normal, underweight, overweight or obese, according to the following table: Less than 18.5 = Underweight 18.5-less than 25 = Normal 25.0-less than 30 = Overweight 30.0 and above = Obese The formula that is used to calculate BMI is 703 X wt in lbs ht in inches You are to write a program which includes a single function, bmi, that takes as arguments a person's weight in pounds and height in inches (both doubles) and returns a bmi_index calculated with the above formula Your main will then 1) ask the person for their weight and height, 2) call the function, and 3) based on the result, tell the person how they are classified. You will be doing this through a series of nested if/else statements. (Note: You may call the function once and store the result, or you may call your function as part of the condition inside the parenthesis of your if statement.) When you have the program written and compiled, test it with your own height and weight, and with some made-up heights and weights. Ideally you should test each path through the program. i.e. for someone underweight, for someone normal, for someone overweight and for someone obese.)Explanation / Answer
#include int main() { double wt_lb, ht_in, bmi, ht_ft; printf("Please enter your weight in whole pounds: "); scanf("%lf", &wt_lb); printf("Please enter your height in whole inches: "); scanf("%lf", &ht_in); ht_ft = ht_in/12; bmi = (703*wt_lb)/(ht_ft*ht_ft); if (bmi < 18.5) { printf("You have a BMI of %.lf, and your weight status is underweight " bmi); } else if (bmi >= 18.5 && bmi < 25) { printf("You have a BMI of %.lf, and your weight status is normal ", bmi); } else { printf("You have a BMI of %.lf, and your weight status is overweight ", bmi); } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.