Question: Create a project titled Lab5_BMR with a single file titled bmr.cpp The program should calculate the person's Basal Metabolic Rate - the number of calories

Create a project titled Lab5_BMR with a single file titled bmr.cpp The program should calculate the person's Basal Metabolic Rate - the number of calories per day a person's body needs to function. Then, on the basis of calculated BMR, your program should output how many doughnuts a person can consume. A medium-size doughnut contains 195 calories.

The BMR formula is as follows:

for women:

 655 + (4.3 x weight in pounds) + (4.7 x height in inches) - (4.7 x age in years) 

for men:

 66 + (6.3 x weight in pounds) + (12.9 x height in inches) - (6.8 x age in years) 

Depending on gender, BMR should be calculated by functions bmrWomen() and bmrMen() that both accept three parameters: "weight in pounds", "height in inches" and "age in years" and return the BMR. Note that the BMR has a fractional part.

The main function should prompt the user for her gender, weight, height and age; compute the BMR and the number of doughnuts that can be consumed per day; and then output both the BMR and the number doughnuts.

The number of doughnuts is: BMR divided by the number of calories in a doughnuts. Fractional number of doughnuts can be dropped. The number of calories per doughnut (195) should be put in a named constant.

On the basis of the user's gender, main() function should decide whether to invoke bmrWomen() or bmrMen(). The user should input her height in feet and inches. The main() function should compute the total number of inches (one foot has 12 inches) and pass it to the bmr functions.

Make sure to use the bmr function prototypes and put the function definitions below the main function definition.

I can't seem to able to input the age and so can't find the BMR. My code is:

#include

#include

#include

#include

using std::cin; using std::cout; using std::endl;

const int Calories = 245;

double bmrWomen(int height, int weight, int years);

double bmrMen(int height, int weight, int years);

int numBagels(double bmr);

int heightConverter(int feet, int inches);

char genderConverter(char gender);

int bmrWomenCalc();

int bmrMenCalc();

int main() {

cout << "Enter your gender (M or F)" << endl;

char gender;

cin >> gender;

gender = genderConverter(gender);

if (gender == 'm') {

bmrMenCalc();

}

else if (gender == 'f') {

bmrWomenCalc();

}

else {

cout << "Error" << endl;

return 1;

}

return 0;

}

double bmrWomen(int weight, int height, int years) {

return 655 + (4.3 * weight) + (4.7 * height) - (4.7 * years);

}

double bmrMen(int weight, int height, int years) {

return 66 + (6.3 * weight) + (12.9 * height) - (6.8 * years);

}

int numBagels(double bmr) {

return floor(bmr / Calories);

}

int heightConverter(int feet, int inches) {

return (feet * 12) + inches;

}

char genderConverter(char gender) {

if (gender == 'm' || gender == 'M') {

return 'm';

}

else if (gender == 'f' || gender == 'F') {

return 'f';

}

else {

return 'x';

}

}

int bmrWomenCalc() {

int weight;

int feet;

int inches;

int years;

cout << "Enter your weight in pounds: ";

cin >> weight;

cout << "Enter your height in feet and inches: ";

cin >> feet >> inches;

cout << "Enter your age in years: ";

cin >> years;

int height;

height = heightConverter(feet, inches);

double bmr;

bmr = bmrWomen(weight, height, years);

int age;

int bagels;

bagels = numBagels(bmr);

cout << "Your BMR is: " << bmr << endl;

cout << "You can eat " << bagels << endl;

return 0;

}

int bmrMenCalc() {

int weight;

int feet;

int inches;

int years;

cout << "Enter your weight in pounds: ";

cin >> weight;

cout << "Enter your height in feet and inches: ";

cin >> feet >> inches;

cout << "Enter your age in years: ";

cin >> years;

int height;

height = heightConverter(feet, inches);

double bmr;

bmr = bmrMen(weight, height, years);

int age;

int bagels;

bagels = numBagels(bmr);

cout << "Your BMR is: " << bmr << endl;

cout << "You can eat " << bagels << endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Your code has a few issues that can be resolved to correctly input the age and calculate the BMR Here are stepbystep suggestions for addressing these ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!