Answer:
Explanation:
//C++ program to calculate the number of chocolate bars to consume in order to maintain one's weight.
#include <iostream>
#include <math.h>
using namespace std;
int main() {
float weight,height;
int age,choice;
char gender;
float bmr;
// inputs
cout<<"\n Enter weight(in pounds) : ";
cin>>weight;
cout<<"\n Enter height(in inches) : ";
cin>>height;
cout<<"\n Enter age(in years) : ";
cin>>age;
cout<<"\n Enter gender(M for male , F for female) : ";
cin>>gender;
cout<<"\n Are you :\n 1. Sedentary \n 2. Somewhat active(exercise occasionally)\n 3. Active(exercise 3-4 days per week)\n 4. Highly active(exercise everyday)? ";
cout<<"\n Choice(1-4) ";
cin>>choice;
//calculate bmr based on the gender
if(gender == 'm' || gender == 'M')
{
bmr = 66+(6.3*weight)+(12.9*height)-(6.8*age);
}else if(gender == 'f' || gender == 'F')
{
bmr = 655+(4.3*weight)+(4.7*height)-(4.7*age);
}
// update bmr based on how active the user is
if(choice ==1)
bmr = bmr + (20*bmr)/100;
else if(choice == 2)
bmr = bmr + (30*bmr)/100;
else if(choice ==3)
bmr = bmr + (40*bmr)/100;
else if(choice ==4)
bmr = bmr + (50*bmr)/100;
// output
cout<<"\n The number of chocolate bar that should be consumed = "<<ceil(bmr/230);
return 0;
}
//end of program