62.4k views
4 votes
Expression for calories burned during workout The following equation estimates the average calories burned for a person when exercising, which is based on a scientific journal article (source): Calories = ( (Age x 0.2757) + (Weight x 0.03295) + (Heart Rate x 1.0781) — 75.4991 ) x Time / 8.368 Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output the average calories burned for a person. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("%.2f", yourValue); Java please

1 Answer

5 votes

Final answer:

The Java program provided computes the average calories burned during exercise based on user inputs for age, weight, heart rate, and time. The formula given in the problem statement is used, and the result is printed with two decimal places.

Step-by-step explanation:

Calculating the average calories burned during a workout involves considering various factors such as age, weight, heart rate, and exercise duration. Below is a Java program that takes inputs for these variables and computes the calories burned:

import java.util.Scanner;

public class ExerciseCaloriesCalculator {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

// Prompt for and read input variables
System.out.print("Enter your age (years): ");
double age = input.nextDouble();
System.out.print("Enter your weight (pounds): ");
double weight = input.nextDouble();
System.out.print("Enter your heart rate (beats per minute): ");
double heartRate = input.nextDouble();
System.out.print("Enter exercise time (minutes): ");
double time = input.nextDouble();

// Calculate calories burned
double caloriesBurned = (((age * 0.2757) + (weight * 0.03295) + (heartRate * 1.0781) - 75.4991) * time) / 8.368;

// Output the result
System.out.printf("Average calories burned: %.2f", caloriesBurned);

input.close();
}
}


This program uses a given formula to compute the calories burned, then it prints the result formatted to two decimal places. Remember to maintain a balanced diet and regular exercise to manage energy expenditure efficiently.

User Alex Kyriakidis
by
8.3k points