Question

in java A way to measure the amount of energy spent during an exercise is to...

in java

A way to measure the amount of energy spent during an exercise is to use metabolic

equivalents (MET). The formula to use is: METs x 3.5 x (weight in kg ) / 200 = calories burned per

minute .

For example, say you weigh 160 pounds (approximately 73 kg) and you play singles tennis,

which has a MET value of 8.

The formula would work as follows: 8 x 3.5 x 73 / 200 = 10.2 calories per minute. If you play

tennis for an hour, you’ll burn about 613 calories. Below are some METS for various activities:

● Running 6 MPH: 10 METS

● Tennis: 8 MEST

● Sleeping: 1 MET

Write a program that accepts an integer the weight of a person and calculates the total number

of calories the person burned while running 6 MPH for 30 minutes, playing tennis for 30

minutes, and sleeping for 9 hours.

Your program should output a single number rounded to an integer.

The table below illustrates output format samples (calculations may not be correct). Here ◦ is

a space and ↵ is a new line character. Your output should look exactly like on the samples

below with any number entered as a weight. Different wording, extra “spaces”, extra “lines”

are graded by the system as a “Wrong-Answer”. Make sure you follow the format.

your program output examples

ex:1

Input person's weight in kg:◦168↵

2290↵

ex:2

Input person's weight in kg:◦173↵

2365↵

Homework Answers

Answer #1
import java.util.*;

class Main {
        public static void main(String[] args) {
                
                Scanner input = new Scanner(System.in);
                
                System.out.print("Input person's weight in kg: ");
                //Reading weight and converting it into KG by multiplying 0.45359237 to it
                double weight = 0.45359237*input.nextDouble();
                // precompute the temp value
                double temp = (3.5*weight)/200;
                //result 
                double result = temp*10*30 + temp*30*8 + temp*9*60*1;
                // rounded result
                int final_result = (int)result;
                // Printing the result
                System.out.print(final_result);
                
        }
}

OUTPUT:

Know the answer?
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
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT