Question

Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and please add comments for the whole code.

Include a class diagrams, and explain the approach you used for the project and how you implemented that, briefly in a few sentences.

Please note the following:
-Names chosen for classes, functions, and variables should effectively convey the purpose and meaning of the named entity.
- Code duplication should be avoided by factoring out common code into separate routines.
- the program should handle exceptions.

Also include the screen shot for the code to see indendation

Computerization of Health Records: A health care issue that has been in the news lately is the computerization of health reco

and target-heart-rate range. Also, the application should display the following information from the Department of Health and

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

// HealthProfile.h

#ifndef HEALTHPROFILE_H
#define HEALTHPROFILE_H

class HealthProfile
{
private:
// Declaring instance variables
string firstname;
string lastname;
string gender;
int day;
int month;
int year;
int weight;
int height;
public :
HealthProfile(string firstname,
string lastname,
string gender,
int day,
int month,
int year,
int weight,
int height);
string getFirstname();
void setFirstname(string firstname);
string getLastname();
void setLastname(string lastname);
string getGender();
void setGender(string gender);
int getDay();
void setDay(int day);
int getMonth();
void setMonth(int month);
int getYear();
void setYear(int year);
int getWeight();
void setWeight(int weight);
int getHeight();
void setHeight(int height);
void changeDOB(int day,int month,int year);
float calculateAge();
  
float * targetHeartRateRange();
double getBMI();
string getCategory();
};
#endif

======================================

// HealthProfile.cpp

#include <iostream>
#include <ctime>
using namespace std;
#include "HealthProfile.h"

HealthProfile::HealthProfile(string firstname,string lastname,string gender,int day,int month,int year,int weight,int height)
{
this->firstname=firstname;
this->lastname=lastname;
this->day=day;
this->month=month;
this->year=year;
this->height=height;
this->weight=weight;
this->gender=gender;
}
string HealthProfile::getFirstname() {
return firstname;
}
void HealthProfile::setFirstname(string firstname) {
this->firstname = firstname;
}
string HealthProfile::getLastname() {
return lastname;
}
void HealthProfile::setLastname(string lastname) {
this->lastname = lastname;
}
string HealthProfile::getGender() {
return gender;
}
void HealthProfile::setGender(string gender) {
this->gender = gender;
}
int HealthProfile::getDay() {
return day;
}
void HealthProfile::setDay(int day) {
this->day = day;
}
int HealthProfile::getMonth() {
return month;
}
void HealthProfile::setMonth(int month) {
this->month = month;
}
int HealthProfile::getYear() {
return year;
}
void HealthProfile::setYear(int year) {
this->year = year;
}
int HealthProfile::getWeight() {
return weight;
}
void HealthProfile::setWeight(int weight) {
this->weight = weight;
}
int HealthProfile::getHeight() {
return height;
}
void HealthProfile::setHeight(int height) {
this->height = height;
}
void HealthProfile::changeDOB(int day,int month,int year)
{
this->day=day;
this->month=month;
this->year=year;
}
float HealthProfile::calculateAge()
{
time_t theTime = time(NULL);
struct tm *aTime = localtime(&theTime);
int currday = aTime->tm_mday;
int currmonth = aTime->tm_mon + 1;
int curryear = aTime->tm_year + 1900;

int months[] = { 31, 28, 31, 30, 31, 30, 31,
31, 30, 31, 30, 31 };
  
if (day > currday) {
currday = currday + months[month - 1];
currmonth = currmonth - 1;
  
}
  
if (month > currmonth) {
curryear = curryear - 1;
currmonth = currmonth + 12;
}
  
int calday = currday - day;
int calmonth = currmonth - month;
int calyear = curryear - year;
  
float tot=(float)(calyear*365+months[calmonth-1]+calday)/365;
  
return tot;
}
  
float * HealthProfile::targetHeartRateRange()
{
// Creating array dynamically
float* range = new float[2];
float min=(220 - calculateAge())*0.50;
float max=(220 - calculateAge())*0.85;
range[0]=min;
range[1]=max;
return range;
}
  
double HealthProfile::getBMI()
{
double bmi = (weight * 703) / (height * height);
  
return bmi;

}

string HealthProfile::getCategory() {
string category = "";
if (getBMI() < 18.5)
category = "UnderWeight";
else if (getBMI() >= 18.5 && getBMI() <= 24.9)
category = "Normal";
else if (getBMI() >= 25 && getBMI() <= 29.9)
category = "OverWeight";
else if (getBMI() >= 30)
category = "Obese";
return category;
}

=============================================

// main.cpp

#include <iostream>
#include <iomanip>
using namespace std;
#include "HealthProfile.h"
int main()
{
//setting the precision to two decimal places
std::cout << std::setprecision(1) << std::fixed;

HealthProfile hp("James","Patinson","M",23,8,1989,162,60);
float * range=hp.targetHeartRateRange();

cout<<"Name :"<<hp.getFirstname()<<" "<<hp.getLastname()<<endl;
cout<<"Gender :"<<hp.getGender()<<endl;
cout<<"Age :"<<hp.calculateAge()<<" years."<<endl;
cout<<"The Target Heart rate Range is "<<range[0]<<" - "<<range[1]<<endl;
cout<<"Your BMI is :"<<hp.getBMI()<<endl;
cout<<"You are :"<<hp.getCategory()<<endl;

return 0;
}

=====================================

Output:

./Health Profile Name : James Patinson Gender :M Age :30.1 years. The Target Heart rate Range is 94.9 - 161.4 Your BMI is :31

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Please write this code in C++ Object-Oriented Programming, specify which files are .h, and .cpp, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Your solution will consist of the following four files: HeartRates.h (class specification file) HeartRates.cpp (class...

    C++ Your solution will consist of the following four files: HeartRates.h (class specification file) HeartRates.cpp (class implementation file) 200_assign4.cpp (application program) 200_assign4.pdf (sample runs) For your fourth programming assignment you will be writing the following C++ program: The formula for calculating your maximum heart rate in beats per minute is 220 minus your age in years. Your target heart rate is a range that is 50-85% of your maximum heart rate. Create a class called HeartRates. The class attributes should...

  • A health care issue that has been in the news lately is the computerization of health...

    A health care issue that has been in the news lately is the computerization of health records. This possibility is being approached cautiously because of sensitive privacy and security concerns, among others. Computerizing health records could make it easier for patients to share their health profiles and history among their various health care professionals. This could improve the quality of health care, help avoid drug conflicts and erroneous drug prescriptions, reduce costs and in emergencies could save lives. In this...

  • Object Oriented Programming Please write the code in C++ Please answer the question in text form...

    Object Oriented Programming Please write the code in C++ Please answer the question in text form 9.5 (complex Class) Create a class called complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form where i is V-I Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it's declared. The constructor should contain default values in...

  • Lab 1: InheritanceTest Write a program called InheritanceTest1.java to support an inheritance hierarchy for class Point–Square–Cube....

    Lab 1: InheritanceTest Write a program called InheritanceTest1.java to support an inheritance hierarchy for class Point–Square–Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class. The private data of Point should be the x-y coordinates, the private data of Square should be the sideLength, and the private data of Cube should be depth. Provide applicable accessor methods, mutator methods, toString() methods, area() method, and volume() method to all classes. Write a program...

  • Programming in C/C++ Submit your source code files (all .h and .cpp files) NO GLOBAL VARIABLES...

    Programming in C/C++ Submit your source code files (all .h and .cpp files) NO GLOBAL VARIABLES Program: Use operator overloaded functions for a birthday club – Based on Chapter 11 lecture (25 pts) Make a class called Birthday that will have a date of month, day, and year and the name. Need to have overloaded operators to compare values along with regular functions like: Overload operator == that takes a Birthdate, compares against the current date values, and returns a...

  • In this module you learned about Object-Oriented programming in C++ and how to combine this approach...

    In this module you learned about Object-Oriented programming in C++ and how to combine this approach with the concepts covered in previous modules For this assignment you will write a class called Dog that has the following member variables: birthyear. An int that holds the dog’s birth year. breed. A string that holds the breed of dog. vaccines. A Boolean holding a yes/no value indicating whether the dog is currently on vaccinations. In addition, the class should have the following...

  • C# P-9 Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming...

    C# P-9 Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming methodologies. Design a class named Contractor. The class should keep the following information: • Contractor name • Contractor number • Contractor start date Write one or more constructors, and the appropriate accessor and mutator functions for the class. For this assignment and P-10 you will have to include an algorithm for you program. This will be a word document attached to the dropbox. Submit...

  • write in java and please code the four classes with the requirements instructed You will be...

    write in java and please code the four classes with the requirements instructed You will be writing a multiclass user management system using the java. Create a program that implements a minimum of four classes. The classes must include: 1. Employee Class with the attributes of Employee ID, First Name, Middle Initial, Last Name, Date of Employment. 2. Employee Type Class that has two instances of EmployeeType objects: salaried and hourly. Each object will have methods that calculates employees payrol...

  • C++ ONLY Please TRAINS DESCRIPTION You are completing a program that allows for several different types...

    C++ ONLY Please TRAINS DESCRIPTION You are completing a program that allows for several different types of passenger trains. One train can hold only cats. Another train can hold only wizards. You are going to create a Wizard class, a Cat class, and a Train class. You are provided the driver, lab2.cpp. The Train class should be a template class where the type of passenger is the template data type. Specifications cat class Attributes: name of cat breed of cat...

  • + Run C Code IMPORTANT: • Run the following code cell to create the input file,...

    + Run C Code IMPORTANT: • Run the following code cell to create the input file, biostats.csv, which you will be using later. 74, In [ ]: N %%file biostats.csv Name, Sex, Age, Alex, M, 41, Bert, M, 42, Dave, M, 39, Elly, F, 30, Fran, F, 33, Jake, M, F, Luke, M, 34, F Myra, M, M, 38, Ruth, F, 28, 22 22 323 47 47, Height, Weight 170 200 167 70 115 143 139 280 98 75, 350...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT