Game Plan Fitness club requires a system that will help their members keep up to date with
their BMI after each training session. The system will allow users to enter their weight and
height and then calculate each member’s BMI, the system must determine their health status
based on the BMI. Use the formula BMI=wieght/(height)^2 , assuming that height is entered
in meters and weight is entered in kilograms. Create a function that calculate the BMI, and
use a post test loop with weight of -1 to terminate the loop.
BMI Health status
Less than 18.4 Underweight
Between 18.5 and 24.9 Healthy weight
Between 25.0 and 29.9 Overweight
Greater than 30.0 Obesity
#include<stdio.h>
#include <math.h>
float BMI_user(float weight,float height){
float BMI = weight / pow(height,2);
return BMI;
}
int main(){
float weight, height, bmi;
weight =0;
do{
printf("Enter the weight\t\n");
scanf("%f", &weight);
printf("\n");
printf("Enter the height\t\n");
scanf("%f", &height);
printf("\n");
//bmi = weight / pow(height,2);
bmi = BMI_user(weight, height);
if(bmi<18.4){
printf("The BMI is %f \nHealth status: Underweight\n", bmi);
}
else if(bmi>18.4 && bmi < 24.9){
printf("The BMI is %f \n Health status: Healthy weight\n", bmi);
}
else if(bmi>25 && bmi < 29){
printf("The BMI is %f \nHealth status: Overweight\n", bmi);
}
else if(bmi>30.0){
printf("The BMI is %f \nHealth status: Obesity\n", bmi);
}
}
while(weight !=-1);
}
Comments
Leave a comment