Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to solve this problem, but I cannot set the function like the text book s

ID: 3861934 • Letter: I

Question

I need to solve this problem, but I cannot set the function like the text book shows. Training Heart Rate In order for exercise to be beneficial to the cardiovascular system, the heart rate (number of heart beats per minute) must exceed a value called the training heart rate, THR. A person's THR can be calculated from his or her age and resting heart rate (pulse rate when first awakening) as follows:

a) Calculate the maximum heart rate as 220 - age.

b) Subtract the resting hear rate from the maximum hear rate.

c) Multiply the result in step (b) by 60%, and then add the resting heart rate.

Write a program to request a person's age and resting heart rate as imput and display his or her THR.

Explanation / Answer

import java.util.*;
class HeartRate {

double trainingHeartRate(int age, int restHeartRate){
double maxHeartRate = 220-age;
maxHeartRate = maxHeartRate - restHeartRate;
maxHeartRate = (maxHeartRate*0.60) +restHeartRate;
  
return maxHeartRate;
  
}

public static void main(String []args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter person's age");
int age = sc.nextInt();
System.out.println("Enter person's resting heart rate");
int heartRate = sc.nextInt();
HeartRate hr = new HeartRate();
double thr = hr.trainingHeartRate(age,heartRate);
System.out.println("person Training heart rate: "+thr);
}
}