Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Description: In this project you are to write a Body Mass Index calculator in C+

ID: 3665277 • Letter: D

Question

Description: In this project you are to write a Body Mass Index calculator in C++. Input will be a person's height in feet and inches as well as their weight in pounds and ounces. The output will be a Body Mass Index and a category that it belongs to (Underweight, Normal, Overweight, Obese).

Details: This project does not require the use of classes or strings. You may assume input is of a valid type. The input for the program will be the height in feet and inches (i.e. 5 8) both integers and weight in pounds and ounces (i.e. 168 3) again, both integers. The output should be a body mass index (double or float) along with the appropriate category. The formula for body mass index using traditional units is:

[weight( pounds)702 ] / [height(inches)^2].

And the categories are:

Underweight BMI < 20.0

Normal 20.0 <= BMI < 25.0

Overweight 25.0 <= BMI < 30.0

Obese 30.0 <= BMI

Hints:

• You should have comments. Your name should appear in the comments at the top of your program.

• Check your answers. Can you input values appropriate for all 4 categories? Do all 4 categories work?

• Build it in small pieces. It is always easier to track down an error when you have only a little bit of new code.

• Use good programming practice. Meaningful variable names, consistent indentation to help readability, small modules.

Explanation / Answer

#include<iostream>
using namespace std;
main()
   {
   int feet,inch,pound,ounce;
   float bmi,inches,pounds;
   cout << "Please enter your height in feet and inches(i.e: 5 8): ";
   cin >>feet>>inch;
   cout << "Please enter your height in pound and ounces(i.e. 168 3): ";
   cin >>pound>>ounce;
   inches=feet*12+inch;   //Convering feets to inches
   pounds=pound+(ounce*0.0625);   //convering ounces to pounds
   bmi=((pounds*702) / (inches*inches));   //calculating BMI from formula
   cout<<bmi;
   if(bmi< 20.0)
       cout<<"BMI: "<<bmi<<" Category: Underweight";
   else if((20.0 <= bmi) && (bmi < 25.0))
       cout<<"BMI: "<<bmi<<" Category: Normal";
   else if((25.0 <= bmi) && (bmi < 30.0))
       cout<<"BMI: "<<bmi<<" Category: Overweight";
   else if(30.0 <= bmi)
       cout<<"BMI: "<<bmi<<" Category: Obese";
   }