C++ problem ... Using Visual studio Express 2010 Create a program that calculate
ID: 3558341 • Letter: C
Question
C++ problem ... Using Visual studio Express 2010
Create a program that calculates a persons Body Mass Index (BMI).
You will need the persons height in inches and their weight in pounds.
The formula to calculate the Body Mass Index is:
BMI = ( W * 703 ) / ( H * H )
Where: BMI = Body Mass Index
W = weight in pounds
H = height in inches
In addition to correctly calculating the numeric value of the BMI, your program should also display the descriptive word that corresponds to the following range of BMI values:
Range of BMI Values
Description
Less than 18.5
Underweight
18.5 or greater, but less than 25
Normal
25 or greater, but less than 30
Overweight
30 or greater
Obese
Your program should do the following:
1. Prompt the user for their weight in pounds.
2. Prompt the user for their height in inches.
3. Echo the weight and height values back to the User.
3. Calculate and display the BMI value.
4. Display the descriptive word that corresponds to their BMI value.
You must:
** Include your name as the programmer in a comment near the top of the file that contains the program
Range of BMI Values
Description
Less than 18.5
Underweight
18.5 or greater, but less than 25
Normal
25 or greater, but less than 30
Overweight
30 or greater
Obese
Explanation / Answer
#include<iostream>
using namespace std;
//Create a program that calculates a persons Body Mass Index (BMI).
// //You will need the persons height in inches and their weight in pounds.
// The formula to calculate the Body Mass Index is:
// BMI = ( W * 703 ) / ( H * H )
// Where: BMI = Body Mass Index
// W = weight in pounds
// H = height in inches
int main()
{
double weight;
double height;
//Your program should do the following:
//1. Prompt the user for their weight in pounds.
cout <<"Enter your weight in pounds :";
cin >> weight;
cout << endl;
//2. Prompt the user for their height in inches.
cout <<"Enter your height in inches :";
cin >> height;
cout << endl;
//3. Echo the weight and height values back to the User.
cout <<"Weight is given by " << weight << endl;
cout <<"Height is given by " << height << endl;
//3. Calculate and display the BMI value.
double bmi = ( weight * 703 ) / ( height * height );
cout <<"BMI given by " << bmi << endl;
//4. Display the descriptive word that corresponds to their BMI value.
//In addition to correctly calculating the numeric value of the BMI, your program should also display the descriptive word that corresponds
//to the following range of BMI values:
// Range of BMI Values Description
// Less than 18.5 Underweight
// 18.5 or greater, but less than 25 Normal
// 25 or greater, but less than 30 Overweight
// 30 or greater Obese
if(bmi < 18.5)
cout << " Underweight " << endl;
else if(bmi >= 18.5 && bmi < 25)
cout << " Normal " << endl;
else if(bmi >= 25 && bmi < 30)
cout << " Overweight " << endl;
else if(bmi >=30)
cout << " Obese " << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.