SHARE
HELP

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.

# Absolute Java

Authors:
Walter Savitch ,kenrick Mock
Exercise:
Programming Projects
Chapter:
Getting Started
Edition:
5
ISBN:
9780132830317
Question:
1
 Previous Next

### 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

Sleeping: 1 MET

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

in kilograms

Write a program that calculates and outputs the total 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.

Program:

``````// CaloriesCalculator.java
public class CaloriesCalculator
{
public static final double KILOGRAMS_PER_POUND = 2.2;
public static final int RUNNING_METS = 10;
public static final int BASKETBALL_METS = 8;
public static final int SLEEPING_METS = 1;

public static void main(String[] args)
{
double weightInKilograms = 150 / KILOGRAMS_PER_POUND;
double runningTimeInMinutes = 30;
double sleepintTimeInMinutes = 6 * 60;

double caloriesBurnedForRunning = 0.0175
* RUNNING_METS * weightInKilograms
* runningTimeInMinutes;

double caloriesBurnedForSleeping = 0.0175
* SLEEPING_METS * weightInKilograms
* sleepintTimeInMinutes;

double totalCaloriesBurned = caloriesBurnedForRunning
+ caloriesBurnedForSleeping;

System.out.println(
"Number of calories burned for running:    "
+ caloriesBurnedForRunning);

System.out.println(
"Number of calories burned for basketball: "

System.out.println(
"Number of calories burned for sleeping:   "
+ caloriesBurnedForSleeping);

System.out.println(
"\nTotal number of calories burned per minute: "
+ totalCaloriesBurned);
}
}``````

Output:

``````Number of calories burned for running:    357.95454545454544
Number of calories burned for basketball: 286.3636363636364
Number of calories burned for sleeping:   429.5454545454545

Total number of calories burned per minute: 1073.8636363636363```
```

### Trueman

Thanks for your great help. Awesome free sevice

Post the discussion to improve the above solution.