### BMR calculator. need revision

1. Write a C++ program to calculate Basal Metabolic Rate and total calorie needs. Use the Harris Benedict equation to calculate calorie needs.
2. The program must use at least three functions or procedures.
3. (See the additional handouts for BMR and Total Calories)
4. The input to the program will be the weight in pounds, the height in inches, the age, and the character 'm' for male and 'f' for female. Read the input data in a procedure using call by reference.
5. The output of the program will be the BMR and Total Calories Needs for each data set. The program must use an end-of-file loop to get credit. Also, echo print the input data for each data set. Write the information in formatted columns with heads.

INPUT:
(FIle included)

OUTPUT:
it looks exactly like the input

Step 1: calculating the BMR

BMR calculation for men : BMR = 66.5 + ( 13.75 x weight in kg ) + ( 5.003 x height in cm ) - ( 6.755 x age in years )
BMR calculation for men : BMR = 66 + ( 6.23 x weight in pounds ) + < 12.7 x height in inches ) - ( 6.76 x age in years )
BMR calculation for women : BMR = 665.1 + ( 9.563 x weight in kg ) + ( 1.850 x height in cm ) - ( 4.676 x age in years )
BMR calculation for women : BMR = 655 + ( 4.35 x weight in pounds ) + ( 4.7 x height in inches ) - (4.7 x age in years )

Step 2: applying the Harris-Benedict Principle

Little to no exercise ------------------------------------------------------------------- Daily calories needed = BMR x 1.2
Light exercise (1-3 days per week)------------------------------------------------- Daily calories needed = BMR x 1.375
Moderate exercise ( 3-5 days per week )------------------------------------------- Daily calories needed = BMR x 1.55
Heavy exercise ( 6-7 days per week ) ----------------------------------------------- Daily calories needed = BMR x 1.725
Very heavy exercise ( twice per day, extra heavy workouts ) -------------------- Daily calories needed = BMR x 1.9

Applications for weight loss

Using the formulae above, a 24-year old, 80 kg male who is 180 cm would have a BMR of 1900. If he exercised moderately, he would multiply his BMR
by his activity level (1900 x 1.55) to determine daily calorie requirements, which would be 2945 kcal per day to keep his weight at 80 kg. This may seem like a high calorie intake, but his activity level requires it. This individual would exercise normally but not lose weight. The same individual without the exercise routine would only be able to consume 2273 kcal per day without gaining weight. The US Department of Health and Human Services Daily Value Guidelines provides figures that support the above example.

Using the Harris-Benedict Equation, individuals can take a mathematical approach to weight loss. There are 3500 calories in 1lb (0..45) of body fat. Using the Harris-Benedict Principle, if someone has a daily allowance of 2500 calories, but he reduces his intake to 2000, then they calculations show a 1 pound loss every 7 days.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162`` ``````#include using namespace std; void male_function (); void female_function (); int main () { int gender; cout << "\n\n"; cout << "This program will calculate your Basal Metabolic Rate" << endl; cout << "Your BMR will tell you roughly how many calories" << endl; cout << "your body burns in a day without any additonal exercise" << endl; cout << "\n\n" << "Let's get started." << endl; cout << "\n\n" << "What is your gender? (1 for female, and 2 for male): "; cin >> gender; while (gender <=0 || gender >= 3) { cout << "\n\n" << "I'm sorry, you entered something other than 1 or 2." << endl; cout << "\n\n" << "Please indicate if you are male or female." << endl; cout << "by entering 1 for female or 2 for male: "; cin >> gender; } if (gender == 1) { female_function (); } else { male_function (); } } void female_function() { const int g2SIZE = 7; char sex2 [g2SIZE] = "Female"; cout << "\n\n"; cout << "You have indicated that you are " << sex2 << endl; cout << "\n\n"; cout << "What is your height in inches? "; int height; cin >> height; //get height while (height < 50 || height > 96) { cout << "\n\n"; cout << "You must be taller than 50 inches" << endl; cout << "Please enter a height between 50 and 96" << endl; cin >> height; } cout << "Thank you." << endl; //get weight cout << "\n\n"; cout << "Now, how much do you weight in pounds? "; int weight; cin >> weight; while (weight < 40 || weight > 450) { cout << "\n\n"; cout << "Please enter a weight more than 40 and 450" << endl; cin >> weight; } cout << "Thank you" << endl; cout << "\n\n"; cout << "Now how old are you (In Years): "; // get age int age; cin >> age; while (age < 10 || age > 80) { cout << "\n\n"; cout << "Im sorry, but this program is not accurate" << endl; cout << "Please enter an age beteeen 10 and 80" << endl; cin >> age; } cout << "\n\nn" << "Calculating BMR..." << endl; double bmr; bmr = 655 + (4.35 * weight) + (4.7 * height) - (4.7 * age); cout << "\n\n"; cout << "Your Basal Metabolic Rate is " << bmr << "." << endl; cout << "\n" << "This is roughly the amount of calories your body will burn in a day" << endl; cout << "without any additional exercise." << endl; cout << "\n\n" << "Now that you know your Basal Metobolic Rate (BMR)" << endl; cout << "Let's take a look at your AMR" << endl; cout << "Your AMR is your BMR adjusted for your activity level. " << endl; cout << "\n\n"; cout << "Please select your activity level; " << endl; cout << "-----------------------------------" << endl; cout << "1. Little to no exercise " << endl; cout << "2. Light exercise (1-3 days per week) " << endl; cout << "3. Moderate exercise ( 3-5 days per week) " << endl; cout << "4. Heavy exercise ( 6-7 days per week ) " << endl; cout << "5. Very heavy exercise (twice per day, extra heavy workouts) " << endl; cout << "\n\n" << "Please enter the number to the left of your activity" ; int selection; if (selection == 1) { amr = bmr * 1.2; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 2) { amr = bmr * 1.375; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 3) { amr = bmr * 1.55; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 4) { amr = bmr * 1.475; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 5) { amr = bmr * 1.9; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } system ("pause"); return 0; }``````
It'd help us to know what exactly you are having trouble with.

One thing I can see is that you haven't declared your amr variable. Just declare it like you did your bmr variable. You'll want to declare it before you do your if statements.

Also, you do not take the selection variable as an input. You'll need to use
 `` `` ``cin >> selection;``

Remove your system("pause"); function, and use something that isn't OS dependent, like getch();
You're a life saver!

 ``123456789101112131415161718192021222324252627282930313233343536373839404142`` ``````int selection; cin>> selection; if (selection == 1) { amr = bmr * 1.2; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 2) { amr = bmr * 1.375; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 3) { amr = bmr * 1.55; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 4) { amr = bmr * 1.725; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; } if (selection == 5) { amr = bmr * 1.9; cout << "\n\n"; cout << "Your BMR is: " << bmr << endl; cout << "Your AMR is: " << amr << endl; }``````

I just did this instead ^^^ and it worked.
Topic archived. No new replies allowed.