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

--------to be written in C++ language(URGENT) Create a class called HeartRates.

ID: 3639284 • Letter: #

Question

--------to be written in C++ language(URGENT)

Create a class called HeartRates. The class attributes should inlcude the person's first name, last name and date of birth. The class should have a constructor that receives this data as parameters. For each attribute, provide set and get functions, and the class should include function getAge that calculates and returns the person's target heart rate. The function getAge should prompt the user to enter the current month, day and year before calculating the person's age.

Write an application that prompts for the person's information, instances an object of class HeartRates and prints the informatio from that object------including the person's first name, last name and date of birth.-----the calculates and prints the person's age in (years), maximum heart rate and target-heart-rate range

Explanation / Answer

please rate - thanks

 


#include <iostream>
using namespace std;
class HeartRates
{
public:
HeartRates(string, string, int,int,int);
void getTargetHeartRate(int,double&,double&);
int getAge();
int getMaximumHeartRate(int );
string getlastName();
string getfirstName();
private:
string firstName;
string lastName;
int month;
int day;
int year;
};

HeartRates::HeartRates(string first, string last, int m,int d,inty)
{
firstName = first;
lastName = last;
month=m;
day=d;
year=y;
} //end HeartRates constructor
string HeartRates::getlastName()
{return lastName;
}
string HeartRates::getfirstName()
{return firstName;
}
void HeartRates::getTargetHeartRate(int m,double& a,double&b)
{a=m*.5;
b=m*.85;
//return TargetHeart;
}//end function getTargetHeartRate
int HeartRates:: getAge()
{int age,m,d,y;
cout<<" Enter todays date: ";
cout<<"Enter month: ";
cin>>m;
cout<<"Enter day: ";
cin>>d;
cout<<"Enter year: ";
cin>>y;
age=y-year;
if(m<month)
    age--;
else if(m==month)
    if(d<day)
       age--;
return age;
}
int HeartRates:: getMaximumHeartRate(int a)
{return 220-a;
}
int main()
{int m,d,y,target,max;
double a,b;
string first,last;
cout<<"Enter first name: ";
cin>>first;
cout<<"Enter last name: ";
cin>>last;
cout<<"Enter Birthday: ";
cout<<"Enter month: ";
cin>>m;
cout<<"Enter day: ";
cin>>d;
cout<<"Enter year: ";
cin>>y;
HeartRates person(first,last,m,d,y);
max=person.getMaximumHeartRate(person.getAge());
cout<<person.getfirstName()<<""<<person.getlastName()<<": ";
cout<<"Has a maximum heart rate:"<<max<<endl;
person.getTargetHeartRate(max,a,b);
cout<<"And a target heart rate range between:"<<a<<" and "<<b<<endl;
system("pause");
return 0;
}