Problem description Your Target Heart Rate is the rate at which your heart shoul
ID: 3857196 • Letter: P
Question
Problem description Your Target Heart Rate is the rate at which your heart should beat to get the maximum benefit from aerobic exercise. This rate is generally agreed to be 60 to 70 percent of your maximal heart rate. Your maximal heart rate equals 220 minus your age. The following diagram shows the valid range for the Target Heart Rate: Maximum heart rate- 220- age M i n i m um target heart rate Maximum heart rate* 60% Maximum target heart rate. Maximum heart rate* 70% Minimum target heart rate Maximumtarget heart rate 60% 70% Maximumheart rate return false return true return false Create a program which includes the following: A main function that asks the user to enter an age and the number of heartbeats counted in one minute These values should be passed to a function that will calculate the Target Heart Rate. You will need to write this function. Make sure you give it a meaningful name. The function you are writing should return true if the user is within his/her Target Heart Rate range and false if not. The main function or driver should then display a message indicating if the user is in his/her Target Heart Rate range. Your main function will use the return value from the function you have written so it (the main function) can display the message. The main should continue prompting and reading in new ages and heart rates until the user enters a negative value for the age.Explanation / Answer
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
bool heart_rate (int, int);
int main()
{
int age;
double minute;
cout<<" Enter Your Age: ";
cin>>age;
bool Targetheartrate = heart_rate(age, minute);
while(age > 0)
{
cout<<" Enter Your heart beats per Minute: ";
cin>>minute;
heart_rate(age, minute);
if(Targetheartrate == true)
{
cout<<" You are in your target heart rate";
cout<<" Enter Your Age: ";
cin>>age;
}
else
{
cout<<" You are not in your target heart rate";
cout<<" Enter Your Age: ";
cin>>age;
}
}
return 0;
}
bool heart_rate(int age, int minute)
{
const int Maximumheartrate = 220 - age;
double Maximumtargetheartrate, Minimumtargetheartrate;
Minimumtargetheartrate = (Maximumheartrate * 0.60);
Maximumtargetheartrate = (Maximumheartrate * 0.70);
if(minute >= Minimumtargetheartrate)
{
if(minute <= Maximumtargetheartrate)
{
return true;
}
}
else
{
return false;
}
}
OUTPUT
Enter Your Age: 21
Enter Your heart beats per Minute: 120
You are in your target heart rate
Enter Your Age: 33
Enter Your heart beats per Minute: 110
You are not in your target heart rate
Enter Your Age:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.