SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,kenrick Mock
Chapter:
C++ Basics
Exercise:
Programming Projects
Question:7 | ISBN:9780132846813 | Edition: 5

Question

One way to measure the amount of energy that is expended during exercise is to use metabolic equivalents (MET). Here are some METS for various activities: Running 6 MPH: 10 METS

Basketball: 8 METS

Sleeping: 1 MET

The number of calories burned per minute may be estimated using the formula Calories/Minute = 0.0175 × 1 MET × (Weight in kilograms)

Write a program that inputs a subject’s weight in pounds, the number of METS for an activity, and the number of minutes spent on that activity, and then out- puts an estimate for the total number of calories burned. One kilogram is equal to 2.2 pounds.


TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Program:

#include <iostream>
#include <string>
using namespace std;

int main()
{
    const double KILOGRAMS_PER_POUND = 2.2;
    
    double weightInPounds;
    int numberOfMETs;
    int numberOfMinutesSpent;
    double weightInKilograms;
    double numberOfCaloriesBurnedPerMinute;
    
    cout << "Enter the weight in pounds: ";
    cin >> weightInPounds;
    
    cout << "Enter the number of METS: ";
    cin >> numberOfMETs;
    
    cout << "Enter the number of minutes spent: ";
    cin >> numberOfMinutesSpent;
    
    weightInKilograms = weightInPounds / KILOGRAMS_PER_POUND;
    
    numberOfCaloriesBurnedPerMinute = 0.0175 * numberOfMETs * weightInKilograms * numberOfMinutesSpent;
    
    cout << "Total number of calories burned: " << numberOfCaloriesBurnedPerMinute << endl;

    return 0;
}

Output:

Enter the weight in pounds: 150                                                                                                                                                               
Enter the number of METS: 9                                                                                                                                                                   
Enter the number of minutes spent: 30                                                                                                                                                         
Total number of calories burned: 322.159 

 

0 0

Discussions

Post the discussion to improve the above solution.