In order for excercise to be beneficial to the cardiovascular system, the heart
ID: 672116 • Letter: I
Question
In order for excercise to be beneficial to the cardiovascular system, the heart rate (number of hear beats per minute) must exceed a value called the training hear reate, 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 hear rate as 220-age.
(b) subtract the resting heart rate from the maximum heart 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 input and display his or her THR.
Explanation / Answer
Please find the program written in C++ as per the requirement:
#include <iostream>
using namespace std;
int main() {
int age,restingHR, maxHR;
float THR;
cout<<"Please enter Age and Resting Heart Rate";
cin>>age>>restingHR;
cout<<endl;
while ((age <= 0) or (restingHR <= 0)){
cout << "Invalid Values. Please enter valid values greater than zeros: "<<endl;
cin>>age>>restingHR;
}
maxHR = 220 - age;
THR = (maxHR - restingHR)*0.6 + restingHR;
cout<<"Training Heart Rate THR is: "<<THR<<endl;
return 0;
}
Testing:
Input:
40 77
Output:
Training Heart Rate THR is: 138.8
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.