Answer to Question #204838 in C++ for Turflot

Question #204838

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. 


1
Expert's answer
2021-06-09T04:24:37-0400
#include <iostream>
using namespace std;
float BMI(float h, float w){
    return w / (h * h);
}
int main(){
    float w, h;
    do{
        cout<<"Input weight: ";
        cin>>w;
        if(w < 0) break;
        cout<<"Input height: ";
        cin>>h;
        float bmi = BMI(h, w);
        cout<<"BMI: "<<bmi<<endl;
        cout<<"Health Status: ";
        if(bmi < 18.4) cout<<"Underweight\n";
        else if(bmi < 24.9) cout<<"Healthy weight\n";
        else if(bmi < 29.9) cout<<"Overweight\n";
        else cout<<"Obesity\n";
    }while(w != -1);
    return 0;
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog