Calories = ( (Age x 0.2757) + (Weight x 0.03295) + (Heart Rate x 1.0781) — 75.4991 ) x Time / 8.368
Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output the average calories burned for a person.
Output each floating-point value with two digits after the decimal point, which can be achieved by executing
cout << fixed << setprecision(2); once before all other cout statements.
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int age;
cout << "Please, enter your age: ";
cin >> age;
float weight;
cout << "Please, enter your weight: ";
cin >> weight;
int heartRate;
cout << "Please, enter your heart rate: ";
cin >> heartRate;
int time;
cout << "Please, enter a time: ";
cin >> time;
double calories = (double)((age*0.2752) + (weight*0.03295) + (heartRate*1.0781) - 75.4991)*time / 8.386;
cout << fixed << setprecision(2)
<< "You burned " << calories << "calories";
}
Comments
Thank for answering the question I was really stuck there
Leave a comment