Repeat Programming Project 5 but in addition ask the user if he or she is a. Sedentary b. Somewhat active (exercise occasionally) c. Active (exercise 3–4 days per week) d. Highly active (exercise every day) If the user answers "Sedentary," then increase the calculated BMR by 20 percent. If the user answers "Somewhat active," then increase the calculated BMR by 30 percent. If the user answers "Active," then increase the calculated BMR by 40 percent. Finally, if the user answers "Highly active," then increase the calculated BMR by 50 percent. Output the number of chocolate bars based on the new BMR value.

Respuesta :

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