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

This is a C++ programming assignment. PLEASE PROVIDE A MAKEFILE FOR THE PROGRAM

ID: 3793350 • Letter: T

Question

This is a C++ programming assignment.
PLEASE PROVIDE A MAKEFILE FOR THE PROGRAM THANKS.

Target Heart-Rate Calculator
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) (www.americanheart.org/presenter.jhtml?identifier=4736) the formula for calculating your maximum heart rate in beats per minute is 220 minus your age in years. Your target heart rate is 50-85% of your maximum heart rate. [Note: These formulas are estimates provided by the AHA. Maximum and target hear 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.]
Create a class called HeartRates. 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 set and get functions. The class should also include a function getAge that calculates and returns the person’s age (in years), a function getMaximumHeartRate that calculates and returns the person’s maximum heart rate, and a function getTargetHeartRate that calculates and returns the person’s target heart rate. Function getAge should prompt the user to enter the current month, day, and year before calculating the person’s age. Write an application (main) that prompts for the person’s information, instantiates an of class HeartRates, and prints the information from that object, including the person’s first name, last name, and date of birth, and then calculates and prints the person’s age in years, the maximum heart rate, and the target heart rate.
Execute your test program and copy the output to a text file, which will demonstrate proper execution.
What to submit:
Please submit a copy of your source code files, a makefile, and a text file(s) that includes the execution output that demonstrates proper operation. PLEASE HELP ME A MAKEFILE AS WELL.......

Explanation / Answer

//Feb_16_heartRate.h

#include<string>
#include<iostream>
using namespace std;

class HeartRates
{
   string fname;
   string lname;
   //declare variable to store date of birth
   int d,m,y;
public:
   HeartRates(string ,string,int m,int d,int y);
   void set_fname(string);
   void set_lname(string);
   void set_date_of_birth(int m,int d,int y );
   int getAge();
   string get_fname();
   string get_lname();
   int getMaximumHeartRate(int age);
   int getTargetHeartRate(int age);
};

--------------------------------------------------------------------------------------------------

//Feb_16_heartRate.cpp

#include"Feb_16_heartRate.h"
HeartRates::HeartRates(string f, string l, int m1, int d1, int y1)
{
   fname = fname;
   lname = l;
   m = m1;
   d = d1;
   y = y1;
}
void HeartRates::set_fname(string f)
{
   fname = f;
}
void HeartRates::set_lname(string l)
{
   lname = l;
}
void HeartRates::set_date_of_birth(int m1, int d1, int y1)
{
   m = m1;
   d = d1;
   y = y1;
}
int HeartRates::getAge()
{
   int m1, d1, y1;
   int age1, age2;
   char t;
   cout << "Enter the current date, month and year in the format month-day-year: ";
   cin >> m1>> t>>d1>>t >> y1;
   if (m >12 || m<1)
       return -1;

   if (m > m1){
       age1 = y1 - y -1;
       age2 = (12 - m) + m1;
   }
   else{
       age1 = y1 - y;
       age2 = 12 - m;
   }
   return age1;
}
string HeartRates::get_fname()
{
   return fname;
}
string HeartRates::get_lname()
{
   return lname;
}
int HeartRates::getMaximumHeartRate(int age)
{
   int rate;
   rate = 220 - age;
   return rate;
}
int HeartRates::getTargetHeartRate(int age)
{
   float target;
   //taking lowest 50%
   target = getMaximumHeartRate(age)*0.5;
   return target;
}

-----------------------------------------------------------------------------------------

//main.cpp

#include"Feb_16_heartRate.h"

int main()
{
   int m, d, y;
   string fname, lname;
   char t;
   //Enter person's detail
   cout << "Enter first name: ";
   cin >> fname;
   cout << "Enter last name: ";
   cin >> lname;
   cout << "Enter the date of birth in format mm-day-year: ";
   cin >> m >> t >> d >> t >> y;
   //instanciate HeartRates object
   HeartRates h(fname,lname,m,d,y);
   int age = h.getAge();
   cout << "Person's Age: " << age << " Maximum heart rate: " << h.getMaximumHeartRate(age) << " Target heart rate: " << h.getTargetHeartRate(age) << endl;
}

--------------------------------------------------------

//Makefile

run:Feb_16_heartRate.o Feb_16_heartRateMain.o
   g++ -o run Feb_16_heartRate.o Feb_16_heartRateMain.o
Feb_16_heartRateMain.o:Feb_16_heartRateMain.cpp Feb_16_heartRate.h
   g++ -c Feb_16_heartRateMain.cpp
Feb_16_heartRate.o:Feb_16_heartRate.cpp Feb_16_heartRate.h
   g++ -c Feb_16_heartRate.cpp
clean:
   rm *.o run

-------------------------------------------------------------------------------

to execute with makefile

execute below line

make run

it should make executable by name run

then run

./run

//output

Enter first name: David
Enter last name: Jack
Enter the date of birth in format mm-day-year: 3-27-1984
Enter the current date, month and year in the format month-day-year: 2-16-2017
Person's Age: 32 Maximum heart rate: 188 Target heart rate: 94

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