LAB: Expression for calories burned during workout Instructor note: Important Coding Guidelines: Please do in C++ Use comments, and whitespaces around operators and assignments. Use line breaks and indent your code. Use naming conventions for variables, functions, methods, and more. This makes it easier to understand the code. Write simple code and do not over complicate the logic. Code exhibits simplicity when it’s well organized, logically minimal, and easily readable. The following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program with inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men. 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. Ex: If the input is: 49 155 148 60 the output is: Women: 580.94 calories Men: 891.47 calories #include #include using namespace std; int main() { Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184; Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184; int cin << ageYears = '49'; cin << weightPounds = '155'; cin << heartBPM = '148'; cin << timeMinutes = '60'; cout << fixed << setprecision(2); cout << "Women: Calories = (ageYears * 0.074) — (weightPounds * 0.05741) + (heartBPM * 0.4472) — 20.4022 ) * timeMinutes / 4.184"; cout << endl; cout << "Men: Calories = (ageYears * 0.2017) + (weightPounds * 0.09036) + (heartBPM * 0.6309) — 55.0969 ) * timeMinutes / 4.18"; cout << endl; return 0; }
LAB: Expression for calories burned during workout
Important Coding Guidelines:
Please do in C++
- Use comments, and whitespaces around operators and assignments.
- Use line breaks and indent your code.
- Use naming conventions for variables, functions, methods, and more. This makes it easier to understand the code.
- Write simple code and do not over complicate the logic. Code exhibits simplicity when it’s well organized, logically minimal, and easily readable.
The following equations estimate the calories burned when exercising (source):
Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184
Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184
Write a program with inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men.
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.
Ex: If the input is:
49 155 148 60the output is:
Women: 580.94 calories Men: 891.47 calories#include <iostream>
#include <iomanip>
using namespace std;
int main() {
Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184;
Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184;
int
cin << ageYears = '49';
cin << weightPounds = '155';
cin << heartBPM = '148';
cin << timeMinutes = '60';
cout << fixed << setprecision(2);
cout << "Women: Calories = (ageYears * 0.074) — (weightPounds * 0.05741) + (heartBPM * 0.4472) — 20.4022 ) * timeMinutes / 4.184";
cout << endl;
cout << "Men: Calories = (ageYears * 0.2017) + (weightPounds * 0.09036) + (heartBPM * 0.6309) — 55.0969 ) * timeMinutes / 4.18";
cout << endl;
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images