c++ full working code Create a class, corresponding getter and setter functions,
ID: 3644075 • Letter: C
Question
c++ full working codeCreate a class, corresponding getter and setter functions, constructors, and an instance to determine BMI.
The body mass index (BMI) is calculated and the program displays a message indicating whether the person has optimal weight, is underweight, or is overweight.
A sedentary person's weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweight.
BMI = weight x 703/height2
Explanation / Answer
#include
#include
using namespace std;
float bmiNumber(float pounds, float inches) //BMI calculation
{
return ((pounds/inches)*703);
}
void chart(int mF)
{
if(mF==2) {
cout<<" Here is some info you might find useful... "
<<"At the same BMI, women tend to have more body fat than men."< <<"From cdc.gov "< }
}
void history()
{
cout<<"Version History"< cout<<" Version 1.0.1(05/18/2012)"< <<"Optimized source code for better program flow, Improved calculation algorithms, "
<<"Introduded looping capabilities for multiple calculations without restarting the program."< cout<<" Version 1.0.0(05/15/2012)"< <<"Creation of the program, very rough outline of the basic structure."< system ("pause");
}
int main()
{
int changes;
int m;
m=1;
cout<<"Hello and welcome to the BMI Calculation Tool 1.0.1, or BMICT1.0.1 for short."<cout<<"If you would like to see the changes from the previous version(1.0.0) please press 3..."<cout<<"If not press any other key.";
cin>>changes;
if(changes==3)
{
history();
}
cout<cout<<"Why don't you first tell me a little bit about yourself, by answering just one simple question."<cout<<"Are you a man or a woman?";
while(m==1)
{
cout<<"If you are a man, please press 1, if you are a woman, please press 2."<cout<<"Please make your selection now..."< cin>>m;
if(m==1)
{
cout<<"Our sources have indicated that you are in fact a man, "
<<"please check to confirm this and continue with the program"< }
else if(m==2)
{
cout<<"Our sources have indicated that you are a woman, "
<<"if this is true please continue with the program"<}
else
{
cout<<"You have entered an incorrect key..."< cout<<"The program will now close. ";
system ("pause");
return 0;
}
chart(m);
float feet;
float inch;
float totalinches;
cout<<"Please enter your height as follows..."< cout<<"Number of feet: "< cin>>feet;
cout<<" Number of inches: "< cin>>inch;
totalinches=(feet*12)+inch;
cout<<"Your total height in inches is: "< float inchSqd;
float lbs;
float BMI;
inchSqd=(totalinches*totalinches);
cout<<"Please enter your weight in pounds: ";
cin>>lbs;
cout<<"Okay, we will now calculate your BMI ";
BMI=bmiNumber(lbs, inchSqd);
cout< <<"Your Body Mass Index Number is: "<
cout< cout< << " Weight Status"< <<" Below 18.5 Underweight"< <<" 18.5 to 24.9 Normal"< <<" 25.0 to 29.9 Overweight"< <<" 30.0 and Above Obese"< cout<<"If you would like to make another calculation press 1, if not press 2..."< cin>>m;
}
cout<
system ("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.