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.