Your Target Heart Rate is the rate at which your heart should beatto get the max
ID: 3614859 • Letter: Y
Question
Your Target Heart Rate is the rate at which your heart should beatto get the maximum benefitfrom aerobic exercise. This rate is generally agreed to be 60to 70 percent of your maximal heart
rate. Your maximal heart rate equals 220 minus yourage. Create a program which includes the
following: A main method that asks the user to enter an age and thenumber of heartbeats
counted in one minute. These values should be passed to amethod that will calculate the Target
Heart Rate. The method should return true if the user iswithin his/her Target Heart Rate range
and false if not. The main method or driver should thendisplay a message indicating if the user
is in his/her Target Heart Rate range. Keep prompting andreading in new ages and heart rates
until the user enters a negative value for the age.
Hint: Make the return type boolean because you’ll bereturning true or false, and put two int’s in
the formal parameter list, one for the age and one for the numberof beats. Name your program
Lab8_Ex2.java.
Explanation / Answer
please rate - thanks import java.util.*; public class Lab8_Ex2 { public static void main(String [] args) {Scanner in=new Scanner(System.in); int age, beats; boolean good; System.out.print("Enter your age: "); age=in.nextInt(); while(age>=0) {System.out.print("Enter the number of heartbeatscounted in one minute: "); beats=in.nextInt(); good=maximal(age,beats); if(good) System.out.println("you are withinyour Target Heart Rate"); else System.out.println("you arenot within your Target Heart Rate"); System.out.println(" Enter your age: "); age=in.nextInt(); } System.exit(0); } public static boolean maximal(int age,int beats)//the code thatfollows? { double maximal; double uprange,lowrange; maximal=220-age; uprange=maximal*.7; lowrange=maximal*.6; System.out.println("Your maximal hearbeats is "+maximal); System.out.println("With a Target Heart Rate range of "+lowrange+"to "+uprange); if(beats>=lowrange&&beatsRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.