Answer to Question #204842 in C++ for Dion Martins

Question #204842

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.


The table below shows the BMI and Health status

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


1
Expert's answer
2021-06-09T04:24:33-0400
#include <iostream>
using namespace std;
float BMI(float height, float weight){
    return weight / (height * height);
}
int main(){
    float weight, height;
    do{
        cout<<"Enter weight: ";
        cin>>weight;
        if(weight < 0) break;
        cout<<"Enter height: ";
        cin>>height;
        float bmi = BMI(height, weight);
        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<<"Obese\n";
    }while(weight != -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