Question
Can someone help me break this down to header file, heart rates.cpp file, and a main.cpp file? #include #include #include #include #include #include using namespace
Can someone help me break this down to header file, heart rates.cpp file, and a main.cpp file?
#include
using namespace std;
class HeartRates {
private: string firstName; // user's first name string lastName; // user's last name int birthMonth; // user's birth month int birthDay; // user's birth day int birthYear; // user's birth year int currentMonth; // current month int currentDay; // current day int currentYear; // current year public: string getFirstName(); string getLastName(); int getBirthMonth(); int getBirthDay(); int getBirthYear(); int getCurrentMonth(); int getCurrentDay(); int getCurrentYear(); void setFirstName(string firstName1); void setLastName(string lastName1); void setBirthMonth(int birthMonth1); void setBirthDay(int birthDay1); void setBirthYear(int birthYear1); void setCurrentMonth(int currentMonth1); void setCurrentDay(int currentDay1); void setCurrentYear(int currentYear1); int getAge(); int getMaximumHeartRate(); string getTargetHeartRate(); };
string HeartRates::getFirstName(){ return firstName; }
string HeartRates::getLastName(){ return lastName; } int HeartRates::getBirthMonth(){ return birthMonth; } int HeartRates::getBirthDay(){ return birthDay; }
int HeartRates::getBirthYear(){ return birthYear; } int HeartRates::getCurrentMonth(){ return currentMonth; } int HeartRates::getCurrentDay(){ return currentDay; } int HeartRates::getCurrentYear(){ return currentYear; }
void HeartRates::setFirstName(string firstName1){ firstName = firstName1;
}
void HeartRates::setLastName(string lastName1){ lastName = lastName1; }
void HeartRates::setBirthMonth(int birthMonth1){ birthMonth = birthMonth1; } void HeartRates::setBirthDay(int birthDay1){ birthDay = birthDay1; }
void HeartRates::setBirthYear(int birthYear1){ birthYear = birthYear1; }
void HeartRates::setCurrentMonth(int currentMonth1){ currentMonth = currentMonth1; }
void HeartRates::setCurrentDay(int currentDay1){ currentDay = currentDay1; } void HeartRates::setCurrentYear(int currentYear1 ){ currentYear = currentYear1; }
int HeartRates::getAge(){
if((birthMonth < currentMonth) || (birthMonth == currentMonth && birthDay < currentDay) ){ return (currentYear -birthYear); } else{ return (currentYear -birthYear - 1); }
}
int HeartRates::getMaximumHeartRate(){ return (220 - getAge()); }
string HeartRates::getTargetHeartRate(){ int MaximumHeartRate = getMaximumHeartRate(); int minTargetHeartRate, maxTargetHeartRate; minTargetHeartRate = .5 * MaximumHeartRate; maxTargetHeartRate = .85 * MaximumHeartRate; ostringstream str1; str1 << minTargetHeartRate; string a = str1.str(); ostringstream str2; str2 << maxTargetHeartRate; string b = str2.str(); string c = a + "-" + b; return c; //return (stoi(minTargetHeartRate) + "-" + stoi(maxTargetHeartRate)); }
int main(){
string firstName; // user's first name string lastName; // user's last name int birthMonth; // user's birth month int birthDay; // user's birth day int birthYear; // user's birth year int currentMonth; // current month int currentDay; // current day int currentYear; // current year HeartRates h; cout << "Please enter First and Last name(Seperated by Spaces):"<
h.setCurrentMonth(currentMonth); h.setCurrentDay(currentDay); h.setCurrentYear(currentYear); cout << "Age: "<< h.getAge() < } This is what I have right now: This is my header file #include class HeartRates { private: std::string firstName; // user's first name std::string lastName; // user's last name int birthMonth; // user's birth month int birthDay; // user's birth day int birthYear; // user's birth year int currentMonth; // current month int currentDay; // current day int currentYear; // current year public: string getFirstName(); string getLastName(); int getBirthMonth(); int getBirthDay(); int getBirthYear(); int getCurrentMonth(); int getCurrentDay(); int getCurrentYear(); void setFirstName(string firstName1); void setLastName(string lastName1); void setBirthMonth(int birthMonth1); void setBirthDay(int birthDay1); void setBirthYear(int birthYear1); void setCurrentMonth(int currentMonth1); void setCurrentDay(int currentDay1); void setCurrentYear(int currentYear1); int getAge(); int getMaximumHeartRate(); string getTargetHeartRate(); }; #endif This is my heart_rates.cpp file #include string HeartRates::getFirstName(){ return firstName; } string HeartRates::getLastName(){ return lastName; } int HeartRates::getBirthMonth(){ return birthMonth; } int HeartRates::getBirthDay(){ return birthDay; } int HeartRates::getBirthYear(){ return birthYear; } int HeartRates::getCurrentMonth(){ return currentMonth; } int HeartRates::getCurrentDay(){ return currentDay; } int HeartRates::getCurrentYear(){ return currentYear; } void HeartRates::setFirstName(string firstName1){ firstName = firstName1; } void HeartRates::setLastName(string lastName1){ lastName = lastName1; } void HeartRates::setBirthMonth(int birthMonth1){ birthMonth = birthMonth1; } void HeartRates::setBirthDay(int birthDay1){ birthDay = birthDay1; } void HeartRates::setBirthYear(int birthYear1){ birthYear = birthYear1; } void HeartRates::setCurrentMonth(int currentMonth1){ currentMonth = currentMonth1; } void HeartRates::setCurrentDay(int currentDay1){ currentDay = currentDay1; } void HeartRates::setCurrentYear(int currentYear1 ){ currentYear = currentYear1; } int HeartRates::getAge(){ if((birthMonth < currentMonth) || (birthMonth == currentMonth && birthDay < currentDay) ){ return (currentYear -birthYear); } else{ return (currentYear -birthYear - 1); } } int HeartRates::getMaximumHeartRate(){ return (220 - getAge()); } This is my main cpp file #include string HeartRates::getTargetHeartRate(){ int MaximumHeartRate = getMaximumHeartRate(); int minTargetHeartRate, maxTargetHeartRate; minTargetHeartRate = .5 * MaximumHeartRate; maxTargetHeartRate = .85 * MaximumHeartRate; ostringstream str1; str1 << minTargetHeartRate; string a = str1.str(); ostringstream str2; str2 << maxTargetHeartRate; string b = str2.str(); string c = a + "-" + b; return c; //return (stoi(minTargetHeartRate) + "-" + stoi(maxTargetHeartRate)); } int main(){ string firstName; // user's first name string lastName; // user's last name int birthMonth; // user's birth month int birthDay; // user's birth day int birthYear; // user's birth year int currentMonth; // current month int currentDay; // current day int currentYear; // current year HeartRates h; cout << "Please enter First and Last name(Seperated by Spaces):"< h.setFirstName(firstName); h.setLastName(lastName); cout << "FirstName: " << h.getFirstName()< h.setCurrentMonth(currentMonth); h.setCurrentDay(currentDay); h.setCurrentYear(currentYear); cout << "Age: "<< h.getAge() < }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started