Answer to Question #125146 in C++ for maham

Question #125146
Write a program that prompts the user to enter a weight in pounds and height in inches and
display the Body Mass Index. Note that one pound is 0.45359237 kilograms and one inch is 0.0254 meters.
Where:
BMI Interpretation
below 16 seriously underweight
16–18 underweight
18–24 normal weight
24–29 overweight
29–35 seriously overweight
above 35 gravely overweight
1
Expert's answer
2020-07-07T14:54:49-0400

#include <iostream>

using namespace std;


int main()

{

// first user prompt

cout << "Please, print a weight

(in pounds)" << endl;


// reading a weight

double pounds;

cin >> pounds;


// second user prompt

cout << "Please, print a height

(in inches)" << endl;


// reading a height

double inches;

cin >> inches;


// calculating bmi

double kilos = pounds * 0.453592;

double meters = inches * 0.0254;

double bmi =

kilos / (meters *meters);

cout << "Your BMI is " << bmi << endl;


// calculating bmi interpretation

if (bmi < 16) 

cout << "Seriously underweight" << endl;

else if (16 <= bmi && bmi < 18)

cout << "Underweight" << endl;

else if (18 <= bmi && bmi < 24)

cout << "Normal weight" << endl;

else if (24 <= bmi && bmi < 29)

cout << "Overweight" << endl;

else if (29 <= bmi && bmi < 35)

cout << "Seriously overweight"

<< endl;

else

cout << "Gravely overweight"

<< endl;


/*

Example:


Please, print a weight (in pounds)

176

Please, print a height (in inches)

70

Your BMI is 25.2531

Overweight

*/

}


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
APPROVED BY CLIENTS