Answer:
// program in C++.
#include <bits/stdc++.h>
using namespace std;
// function to calculate calories burned
double calories_burned(int age,int weight,int heart_rate,int time_i, char gen)
{
// variable
double calories=0;
if(gen=='m')
// calories burned by men
calories = ((age * 0.2017 )- (weight * 0.09036) + (heart_rate * 0.6309) - 55.0969) * (time_i / 4.184);
else if(gen=='f')
// calories burned by Women
calories = ((age * 0.074) - (weight * 0.05741) + (heart_rate * 0.4472) - 20.4022) * (time_i / 4.184);
// return calories burned
return calories;
}
// main function
int main()
{
// variables
int age,weight,heart_rate,time_i;
cout<<"Enter age (years):";
// read age
cin>>age;
cout<<"Enter weight (pounds):";
// read weight
cin>>weight;
cout<<"Enter heart rate (beats per minute):";
// read heart_rate
cin>>heart_rate;
cout<<"Enter time (minutes):";
// read time
cin>>time_i;
// call function for men
double men_cal=calories_burned(age,weight,heart_rate,time_i,'m');
// call function for women
double women_cal=calories_burned(age,weight,heart_rate,time_i,'f');
// print calories burned by men
cout<<"Men calories burned :"<<men_cal<<endl;
// print calories burned by Women
cout<<"Women calories burned :"<<women_cal<<endl;
return 0;
}
Step-by-step explanation:
Read age, weight, heart rate and time from user.Then call the function calories_burned() with all the input and a character parameter for men.This function will calculate the total calories burned by the men.Similarly call the function again for women, Then it will return the calories burned by women.Print the calories burned by men and women.
Output:
Enter age (years):25
Enter weight (pounds):160
Enter heart rate (beats per minute):125
Enter time (minutes):60
Men calories burned :205.791
Women calories burned :403.856