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

You need to document your code make sure they are readable (comment please) Whil

ID: 3556181 • Letter: Y

Question

You need to document your code make sure they are readable (comment please)

While exercising, you can use a heart-rate monitor to see that your heart rate stays within a safe range suggested by your trainers and doctors. According to the American Heart Association (AHA), the formula for calculating your maximum heart rate in beats per minute is 220 minus your age in years. Your target heart rate is a range that's 50-85% of your maximum heart rate.1 Create a class called HeartRates with both an interface and implementation file. The class attributes should include the person's first name, last name and date of birth (consisting of separate attributes for the month, day and year of birth). Your class should have a constructor that receives this data as parameters. For each attribute provide accessor and mutator (get and set functions. The class also should include a function that calculates andreturns the person's age (in years)2, a function that calculates and returns the person's maximum heart rate, and a function that calculates and returns the person's target heart rate range. Write a C++ application that prompts for the person's information, instantiates an object of class HeartRates and prints the information from that including the person's first name, last name and date of birth-then calculates and prints the person's age in ears maximum heart rate and target-heart-rate range. These formulas are estimates provided by the AHA. Maximum and target heart rates may vary based on the health, fitness and gender of the individual. Always consult a physician or qualified health care professional before beginning or modifying an exercise program. 2 You must know the current year to calculate a person's age. You can use the following code to query the system for this information #include time( NULL get current time time t struct tim tstruct *localtime & convert to local time zone tstruct.tm year 1900 compute current year int year

Explanation / Answer

#include <iostream>
#include <string>

using namespace std;

//Class for Heart Rate
class HeartRate {

public:
HeartRate (string, string, int, int, int); // constructor for the class

void setFirstName ( string ); // function for name
string getFirstName (); // function to return first name

void setLastName ( string ); // function for last name
string getLastName (); // function to return last name

void setDateOfBirth ( int, int, int); // Function to set date of birth
int getDateOfBirth ();

int getAge (); // function to get age
int getMaximumHeartRate (); // function to get Maximum Heart Rate
int getTargetHeartRate (); // function to get Target Heart Rate

private:

string fName; // Constructor's first name
string lName; // Constructor's last name
int month; // Constructor's month
int day; // Constructor's day
int year; // Constructor's year
int yearToday; // Present year
int birthYear; // Year of birth

}; // end of function

Definition of the methods (HeartRate.cpp)

//Program definition for Heart beat rate
#include <iostream>
#include <string>
#include "HeartRate.h"


//While solving this question, thoughts about how best to create the constructor with having to had parameters
using namespace std;

HeartRate::HeartRate ( string fNamel, string lNamel, int monthl, int dayl, int yearl){

setFirstName (fNamel);
setLastName ( lName );
setDateOfBirth ( monthl, dayl, yearl);

}

void HeartRate::setFirstName ( string fNamel) { // function for set first name
fName = fNamel;
}

void HeartRate::setLastName ( string lNamel ){ // function for set last name
lName = lNamel;
}

void HeartRate::setDateOfBirth ( int monthl, int dayl, int yearl) { // function for set date of birth
month = monthl;
day = dayl;
year = yearl;
}

string HeartRate::getFirstName (){ // function to return first name
return fName;
}

string HeartRate::getLastName(){ // function to return last name
return lName;
}

int HeartRate::getDateOfBirth () { // function for date of birth
return 0;

}

int HeartRate::getAge () { // function to calculate age
int monthB, dayB, yearB, yearT;
cout << "Enter your date of birth in format: month day year" << endl;
cin >> monthB >> dayB >> yearB;

cout << "Enter current year: " << endl;
cin >> yearT;
yearToday = yearT;
birthYear = yearB;
cout << endl;
cout << "Your date of birth is: "<< monthB << "/" << dayB << "/" << yearB << endl;
cout << endl;
cout << "Your age is: " << (yearToday - birthYear) << endl;
return 0;

}

int HeartRate::getMaximumHeartRate () { //function for the maximum heart rate
cout << "Your maximum heart rate is: " << 220- (yearToday - birthYear) << endl;
return 0;
}

int HeartRate::getTargetHeartRate () { // function for the target heart rater
cout << "Your target heart rate range is: " << (0.5 * (220-(yearToday - birthYear))) << " - " << (0.85 * (220-(yearToday - birthYear))) << endl;
return 0;
}


Main Method (ex03_316.cpp)

//Program for the main

#include <iostream>
#include <string>
#include "HeartRate.h"

using namespace std;

int main () {
string firstName, lastName;
HeartRate myHeartRate ( "*", "*", day(**), month(**), year (****));

cout << " Enter your Name " << endl;
cin >> lastName >> firstName;
cout << "Your name is: " << lastName << " "<< firstName << endl;


myHeartRate.getAge ();
myHeartRate.getMaximumHeartRate ();
myHeartRate.getTargetHeartRate ();

return 0;
}

The asterisks are required inputs from the user in the formats expected as defined in the Declaration.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote