Answer to Question #114860 in C++ for redomoditswe

Question #114860
BMI or Body Mass Index is a method of estimating a person's body fat levels based on a person's 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 kg/m2. BMI formula: BMI = weight /(height)2 BMI Weight status Below 18.5 Underweight 18.5‐24.9 Healthy 25.0‐29.9 Overweight 30.0 and above Obese

Write a program that calculates a person’s BMI and displays the weight status according to the BMI 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; (5) 1.2. calcBMI to calculate the BMI ; (5) 1.3. displayFitnessResults to display the BMI and relevant weight status message; (5) 1.4. ma
1
Expert's answer
2020-05-11T12:42:44-0400
#include <iostream>
#include <vector>


using namespace std;


//getData function
vector<double> getData() {
	double a, b;
	cout << "Enter your mass(kg): ";
	cin >> a;
	cout << "Enter your height(m): ";
	cin >> b;
	vector<double> c;
	c.push_back(a);
	c.push_back(b);
	return c;
}
//calcBMI function
double calcBMI(vector<double> c){
	double t = c[0] / (c[1] * c[1]);
	return t;
}
//displayFitnessResults function
void displayFitnessResults(double t) {
	if (t < 18.5)
		cout << "Underweight";
	if (t >= 18.5 && t < 25)
		cout << "Healthy";
	if (t >= 25 && t < 30)
		cout << "Overweight";
	if (t >= 30)
		cout << "Obese";
}


int main() {
	vector<double> c;
	double t;
	c=getData();
	t = calcBMI(c);
	displayFitnessResults(t);
	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
APPROVED BY CLIENTS