Question

One way to measure the amount of energy that is expended during exercise is to use...

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 × MET × Weight(Kg)

Write a program that calculates and outputs the tot al number of calories burned for a 150 pound person who runs 6 MPH for 30 minutes, plays basketball for 30 minutes, and then sleeps for 6 hours. One kilogram is equal to 2.2 pounds.


You must create a class level/scope variable for every "constant" value that you have, such as the number of METS per each activity - there are several others as well that will not change no matter how many different scenarios this program is run for, so make sure they are all defined this way and other values that could vary if you ran it for different people/scenarios can be declared as method level/scope variables (in your main() method in this case). For now, declare all of your class level/scope variables as "public static final".

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

source code:

language:Java

import java.text.DecimalFormat;
class energy{
   public static void main(String args[]){

    //declaring important constants with MET values

   final int running=10;//MET for running is 10,according to the question

   final int basketball=8;//MET for basketball is 8,according to the question

   final int sleeping=1;//MET for sleeping is 1,according to the question

   int weight=150;//given that person weight is 150 pounds

   double weight_in_kg;//for calculating weight in kilograms

   weight_in_kg=weight/2.2;//1kg=2.2 pounds,based on that calculating kilogram value

   double energy_running;//to store energy used for running

   energy_running=0.0175*running*weight_in_kg*30;//calculating based on given formula,multiplying with 30,here 30 is minutes

   double energy_basketball;//to store energy used for basketball

   energy_basketball=0.0175*basketball*weight_in_kg*30;//calculating based on given formula,multiplying with 30,here 30 is minutes

   double energy_sleeping;//to store energy used for sleeping

   energy_sleeping=0.0175*sleeping*weight_in_kg*(6*60);//calculating based on given formula,multiplying with (6*60),here (6*60) is minutes

   double total;//to store total number of calories

   total=energy_running+energy_basketball+energy_sleeping;//adding all calculated energies,to get final amount of energy
   DecimalFormat formatter = new DecimalFormat(".##"); //to print upto 2 decimal places only
      
   System.out.println("total amount of energy used in terms of calories is :" + formatter.format(total));
   }
}

output:

Add a comment
Know the answer?
Add Answer to:
One way to measure the amount of energy that is expended during exercise is to use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT