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

The Harris-Benedict equation estimates the number of calories your body needs to

ID: 3665001 • Letter: T

Question

The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exercise whatsoever. This is called your basal metabolic rate, or BMR (note this is a single variable name, not three variables multiplied together). The formula for the calories needed for a woman to maintain her weight is

BMR = 655 + (4.3×weight in pounds) + (4.7×height in inches)(4.7×age in years).

The formula for the calories needed for a man to maintain his weight is

BMR = 66 + (6.3×weight in pounds) + (12.9×height in inches)(6.8×age in years).

A typical chocolate bar contains approximately 230 calories. Write a program that allows the user to input his or her weight in pounds, height in inches, age in years, and the character ‘M’ for male or ‘F’ for female. The program should then output the number of 230 calorie chocolate bars that need to be consumed to maintain one’s weight for a person of the input sex, height, weight, and age.

note: the program should be in C++ language.

Explanation / Answer

BMRCalc.cpp

#include<iostream>
using namespace std;


int main()
{
   double BMR = 0;
   double weight = 0, height = 0;
   int age = 0;
   char gender = ' ';
   cout << "Enter your weight in pounds" << endl;
   cin >> weight;
   cout << "Enter your height in inches" << endl;
   cin >> height;
   cout << "Enter your age in years" << endl;
   cin >> age;
   cout << "Enter your gender M for male and F for female" << endl;
   cin >> gender;

   const char* sex = "";

   if (gender == 'F')
   {
       BMR = 655 + (4.3*weight) + (4.7*height)-(4.7*age);
       sex = "Female";
   }
   else
   {
       BMR = 66 + (6.3*weight) + (12.9*height)-(6.8*age);
       sex = "Male";
   }

   double chocNum = BMR / (double)230;
   cout <<"Number of 230 calorie chocolate bars that need to be consumed"
       <<" to maintain one's weight for a person of sex "<<sex<<" height "<<height<<" inches weight "<<weight
       <<" pounds and age "<<age<<"years are "<<endl;
   cout << chocNum << endl;
   return 0;
}

sample output:

Enter your weight in pounds
178.5
Enter your height in inches
60
Enter your age in years
23
Enter your gender M for male and F for female
M
Number of 230 calorie chocolate bars that need to be consumed to maintain one's
weight for a person of sex Male height 60 inches weight 178.5 pounds and age 23y
ears are
7.86152
Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote