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: MET

The number of calories burned per minute may be estimated using the formula

Calories/Minute= 0.0175 X MET X Weight (Kg)

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 activitym and then outputs an estimate for the total number of calories burned. One kilogram is equal to 2.2 pounds.

Dani AI

Generated

A small, well-scoped task. and correctly set the problem into the input → convert → compute → output steps, and supplied a working example. As reminded, the forum favors guidance that helps learning rather than just handing over a finished program. The notes below focus on practical improvements that make the solution clearer, safer, and easier to extend.

Prefer floating-point types for weight, MET and duration so fractional input is not lost; integer variables will silently truncate values. Use a named constant for the pounds-to-kilogram factor (2.20462 gives better precision than 2.2) and ensure the conversion uses floating-point division. Validate inputs: treat zero or negative weight, MET, or minutes as invalid and handle them predictably. Format the final calorie value to a reasonable number of decimal places for readability. Encapsulate the computation in a small function to separate I/O from logic — this makes unit testing and reuse straightforward. Choose clear, descriptive variable names so the calculation reads like a sentence.

Prefer running the program in a terminal or IDE run window instead of relying on platform-specific console hacks. Verify correctness with a few representative test cases and with edge values (very small and very large inputs) to check rounding and stability. For future enhancements, consider supporting multiple activities per session, reading MET values from a small lookup table, or logging results to a file. These small design choices improve portability, accuracy, and maintainability while keeping the core calculation intact.

Recommended Answers

All 7 Replies

Get weight value from user.
Get MET score for activity.
Get time spent doing activity.
Output (0.0175 * MET * time * weight/2.2)

Which of those can you not do?

Please read the rules here.

7. Do not ask for code. We are not a coding service. We will help you fix your code.
If anyone posts a complete working solution for you, they are enabling cheaters.
If you use that code you are a cheater.

We can help you to show the path but you should write your own code. If you face any problem regarding your code you can share it. If you don't know coding you can learn it. Here are some reference books. You can find lots of free books and video tutorial for coding. If you ask for code that will not help you to learn How to Code.

the weight value?

I'll take that to mean you don't know how to take in the weight value from the user. This is, as a general rule, one of the first things in the textbook or class notes. Here is how to get a value from the user:

cin >> someVariable;

If you are trying to prompt user for data, try this.

cout<<"please enter your data here";
cin>>dataVariable;
#include <iostream>
using namespace std;

int main()
{
    int mets;
    double fatnessKg, fatnessLb, energy, mins;

    cout << "METS:\n"
         << "\tRunning: 6Mph = 10 METS\n"
         << "\tBasketball: 8 METS\n"
         << "\tSleeping: MET\n";



    system ("pause");
    return 0;
}
#include <iostream>

using namespace std;

int main()
{
   double CAL,MET,MINS,WEI;
   
   CAL = MET = MINS = WEI = 0;

   cout<<"Enter you weight in pounds:";
   cin>>WEI;
  
   cout<<"Enter MET number:";
   cin>>MET;

   cout<<"Enter the duration in mins:";
   cin>>MINS;

   CAL = 0.0175 * MET * WEI/2.2;
   CAL = CAL * MINS;
   cout<<"Total Calories:"<<CAL<<endl;


   return 0;


}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.