The first screenshot contains the modified instructions.
Above is a screen shot of the header file. Here is the code:
#include <string>
class HeartRate
{
public:
explicit HeartRate(std::string,std::string, int, int, int, int, int, int);
std::string getLastName()const;
std::string getFirstName() const;
int getBirthMonth() const;
int getBirthDay()const;
int getBirthYear()const;
int getCurMonth()const;
int getCurDay() const;
int getCurYear()const;
int getAge();
int getMaxHr();
float getTargetHeartRate50();
float getTargetHeartRate85();
private:
std::string firstName;
std::string lastName;
int bMonth;
int bDay;
int bYear;
int age;
int hr;
int curMonth;
int curYear;
int curDay;
int maxHr;
float targetHr50;
float targetHr85;
};
The next screen shot is the heartrate.cpp
Here is the full code for the heartrate cpp. You can't see it all in the picture.
#include <iostream>
#include "HeartRate.h"
using namespace std;
HeartRate::HeartRate(string fname,string lname, int bM, int bD, int bY, int cM, int cD, int cY)
:firstName(fname), lastName(lname), bMonth(bM), bDay(bD), bYear(bY), curMonth(cM), curDay(cD), curYear(cY)
{
}
string HeartRate::getFirstName() const
{
return firstName;
}
string HeartRate::getLastName() const
{
return lastName;
}
int HeartRate::getBirthMonth() const
{
return bMonth;
}
int HeartRate::getBirthDay() const
{
return bDay;
}
int HeartRate::getBirthYear() const
{
return bYear;
}
int HeartRate::getCurMonth() const
{
return curMonth;
}
int HeartRate::getCurDay() const
{
return curDay;
}
int HeartRate::getCurYear() const
{
return curYear;
}
int HeartRate::getAge()
{
int age = curYear-bYear;
if (curMonth < bMonth)
return age - 1;
if ( curMonth==bMonth )
if(curDay<bDay)
return age - 1;
return age;
}
int HeartRate::getMaxHr()
{
int age= curYear-bYear;
int maxHr = 220 - age;
return maxHr;
}
float HeartRate::getTargetHeartRate50()
{
int age = curYear-bYear;
int maxHr = 220- age;
float targetHr50 = maxHr *.50;
return targetHr50;
}
float HeartRate::getTargetHeartRate85()
{
int age = curYear-bYear;
int maxHr = 220- age;
float targetHr85 = maxHr *.85;
return targetHr85;
}
Next is the main cpp:
Here is the code:
#include <iostream>
#include "HeartRate.h"
using namespace std;
int main()
{
std::string firstName;
std::string lastName;
int bMonth;
int bDay;
int bYear;
int curMonth;
int curDay;
int curYear;
//int age; this is not needed
//int maxHr; this is not needed
cout << "Enter your first name " ;
cin >> firstName;
cout << "Enter your last name ";
cin >> lastName;
cout << "Enter your birth month as an integer ";
cin >> bMonth;
cout << "Enter your day of birth as an integer ";
cin >> bDay;
cout << "Enter your birth year as a four digit integer ";
cin >> bYear;
cout << "Please enter the current month " ;
cin >> curMonth;
cout << "Please enter the current day " ;
cin >> curDay;
cout << "Please enter the current year " ;
cin >> curYear;
cout << endl;
HeartRate myHR(firstName,lastName,bMonth,bDay,bYear,curMonth,curDay,curYear);
HeartRate anything(firstName,lastName,bMonth,bDay,bYear,curMonth,curDay,curYear);
cout << "Hello " << myHR.getFirstName() <<" " << myHR.getLastName() << "\n";
cout << "Birthdate " << myHR.getBirthMonth()<<"/"<<myHR.getBirthDay()<<"/"<<myHR.getBirthYear() <<"\n";
cout << endl;
cout << "Your age is " << anything.getAge(); cout <<endl;
cout << "Your maximum heart rate is " << anything.getMaxHr(); cout <<endl;
cout << "Your target heart rate should be between " << anything.getTargetHeartRate50() << " and " << anything.getTargetHeartRate85(); cout << endl;
cout << endl;
return 0;
}
That's really cool job...
ReplyDeleteHello everyone, I want to say a special thanks to Dr OGU. for helping me get cured from herpes virus 2019 , I contacted him base on the testimonies I saw about him on the internet I was diagnosed of HERPES Virus i have tried all I can to get cured but all to know avail, until i saw a post in a health forum about a herbal man who prepare herbal medication to cure all kind of diseases including HERPES virus, at first i doubted if it was real but decided to give it a try I was cured by his herbal medicine and natural herbs, kindly contact him today through his email: drogugusolutionhome@gmail.com or text/call: +1 (719) 629 0982
ReplyDeleteHe’s waiting to help you.
HE ALSO SPECIALIZE IN THE FOLLOWING Illness;
If you have any sickness like : H I V/AIDS , CANCER , HERPES 1 or 2 , GENITAL WARTS (HPV), and Hepatitis A, B. Trichomoniasis Gonorrhea, Epilepsy, and Syphilis.