Using C++ BMI or Body Mass Index weight and height measurement. The BMI is calcu
ID: 3749737 • Letter: U
Question
Using C++
BMI or Body Mass Index weight and height measurement. The BMI is calculated by dividing the person's body mass/weight (in kilograms) by the square of the body height (in metres). The result is universally expressed in units of ke/m2. BMI formula: BMI - weight /(height) is a method of estimating a person's body fat levels based on a person's BMI Below 18.5 18.5-24.9 25.0-29.9 30.0 and aboveObese Weight status Underweight Healthy Overweight Write a program that calculates a person's BMI and displays the weight status according to the BM value, indicating whether the person is underweight, healthy, overweight or obese. The BMI weight statuses and related values are listed in the above table. The program should have the following functions: 1.1. getData that prompts and returns their weight and height 1.2. calcêMI to ealculate the BMi 1.3. displayEstnessResUs to display the BMI and relevant weight status message: (5) 1.4. main function (15)Explanation / Answer
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//global variables
float weight;
float height;
//dislay the desired result
void displayFitnessResults(float n){
if(n<18.5){
cout<<"BMI : "<<n<<" Weight Status : Underweight"<<endl;
}else if(n>=18.5 && n<25){
cout<<"BMI : "<<n<<" Weight Status : Healthy"<<endl;
}else if(n>=25 && n<30){
cout<<"BMI : "<<n<<" Weight Status : Overweight"<<endl;
}else if(n>=30){
cout<<"BMI : "<<n<<" Weight Status : Obese"<<endl;
}
}
//calculating the BMI of the user
float calcBMI(float w, float h){
return (w/(h*h));
}
//taking input of weight and height from the user
void getData(){
cout<<"Please enter your weight in kilograms(kg) : ";
cin>>weight;
cout<<"Please enter your height in meters(m) : ";
cin>>height;
}
int main()
{
float result;
//take the input from user using this function
getData();
//store the calculated BMI in the variable
result = calcBMI(weight, height);
//display the desired result to the user
displayFitnessResults(result);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.