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. Target Heart-Rate Calculator While exercis

ID: 3791085 • Letter: T

Question

This is a C++ programming assignment.

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.

Explanation / Answer

#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

class HeartRates
{
   public:
       string fname;
       string lname;
       int year;
       int month;
       int day;
       int age=0;
   int maximumH=0;
       HeartRates(string first,string last,int y,int m,int d)
       {
           fname=first;
           lname=last;
           year=y;
           month=m;
           day=d;
       }

int getAge()
{
   int currentyear=2017;
   age=currentyear-year;
   return age;
   }
   int maximumHeartRate()
   {
       maximumH= 220-age;
       return maximumH;
   }
  
   double targetHeartRate()
   {
       double percentage=0;
       cout<<"enter the percentage"<<endl;
       cin>>percentage;
   double   targetH=maximumH*(percentage/100);
       return targetH;
      
   }
      
};

int main()
{
   string first,last;
   int year,month,day;
   cout<<"enter the first name"<<endl;
   cin>>first;
   cout<<"enter the last name"<<endl;
   cin>>last;
   cout<<"entet the year"<<endl;
   cin>>year;
   cout<<"enter the month"<<endl;
   cin>>month;
   cout<<"enter the day"<<endl;
   cin>>day;
  
   HeartRates hrates(first,last,year,month,day);
   int page=hrates.getAge();
   cout<<"the age in years is :"<<page<<endl;
   int mrate=hrates.maximumHeartRate();
   cout<<"maximum heart rate is : "<<mrate<<endl;
   double trate=hrates.targetHeartRate();
   cout<<"target heart rate is :"<<trate<<endl;
  
}

output

enter the first name
mark
enter the last name
smith
entet the year
1990
enter the month
02
enter the day
01
the age in years is :27
maximum heart rate is : 193
enter the percentage
55
target heart rate is :106.15

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