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; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question

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 <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;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning