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

Create a class specification (DogHealth.h) & class implementation (DogHealth.cpp

ID: 3881807 • Letter: C

Question

Create a class specification (DogHealth.h) & class implementation (DogHealth.cpp) file for a class named DogHealth. The purpose of the DogHealth class is to allow a user to enter in information about a dog and then get statistics based on that information. DogHealth should have the following attributes . The dog's name (string) The dog's age (integer) A floating point array holding 12 months of the dog's weight in pounds (one weight entered per month) An integer array holding 12 months of the dog's resting heart rate in beats per minute (one resting heart rate per month) · · DogHealper should have the following member functions: Constructor- should ask the user for the name, age, and all the data for the two arrays and enter in the information in to the attributes. printDogHealth - has no parameters or return data and should just print out all the information in the attributes . printWeightStatistics should create a NEW ArrayHelper object sending the weight array & number of elements in the array to this object. Should then call the getMax, getMin, and getAvg functions of the ArrayHelper object in order to print o month that the dog had the highest weight and the weight amount o month that the dog had the lowest weight and the weight amount o the average weight of all the months printHeartRateStatistics - should create a NEW ArrayHelper object sending the heartrate array & number of elements in the array to this object. Should then call the getMax, getMin, and getAvg functions of the ArrayHelper object in order to print: o o o month that the dog had the highest resting heart rate and the resting heart rate amount month that the dog had the lowest resting heart rate and the resting heart rate amount the average resting heart rate of all the months

Explanation / Answer

// DogHealth.h

#ifndef DOGHEALTH_H

#define DOGHEALTH_H

#include <string>

using namespace std;

class DogHealth{

private:

string name;

int age;

double weightArray[12];

int heartRateArray[12];

public:

DogHealth();

void printDogHealth();

void printWeightStatistics();

void printHeartRateStatistics();  

};

#endif

//DogHealth.cpp

#include "DogHealth.h"

#include "ArrayHelper.h"

#include <iostream>

#include <string>

using namespace std;

DogHealth::DogHealth(){

cout << "Please Enter Dogs details"<<endl;

cout << "Enter Dogs name" << endl;

cin >> name;

cout << "Enter "<< name << "'s age" << endl;

cin >> age;

cout << "Enter "<< name << "'s weight for last 12 months" << endl;

for(int i = 0; i< 12; i++){

cout << "Enter weitht for month number" << i << endl;

cin >> weightArray[i];  

}

cout << "Enter "<< name << "'s Heart rate for last 12 months" << endl;

for(int i = 0; i< 12; i++){

cout << "Enter weitht for month number" << i << endl;

cin >> heartRateArray[i];  

}  

}

void DogHealth::printDogHealth(){

cout << "The detais of Dog" << name << "are: " <<endl;

cout << "Name: " << name <<endl;

cout << "Age: " << age <<endl;

cout <<" Weight details of last 12 months are " <<endl;

for(int i = 0; i< 12; i++){   

cout << weightArray[i] << " ";  

}  

cout << endl;

  

cout <<" Heart details of last 12 months are " <<endl;

for(int i = 0; i< 12; i++){   

cout << heartRateArray[i] << " ";  

}  

}

void DogHealth::printWeightStatistics(){

cout << "This is a printWeightRateStatistics statement" <<endl;

double *p = weightArray;

ArrayHelper arrayObject(p, 12);

cout << "Max Weigh :" << arrayObject.getMax() << endl;

cout << "Min Weigh :" << arrayObject.getMin()<< endl;

cout << "Avg Weigh :" << arrayObject.getAverage()<< endl;  

}

void DogHealth::printHeartRateStatistics(){

cout << "This is a printHeartRateStatistics statement" <<endl;

int *p = heartRateArray;

ArrayHelper arrayObject(p, 12);

cout << "Max HeartRate ;" << arrayObject.getMax() << endl;

cout << "Min HeartRate ;" << arrayObject.getMin()<< endl;

cout << "Avg HeartRate ;" << arrayObject.getAverage()<< endl;  

}

// ArrayHelper.h

#ifndef ARRAYHELPER_H

#define ARRAYHELPER_H

#include <string>

using namespace std;

class ArrayHelper{

private:

int size;

double *Array;

public:

ArrayHelper(double *valueArray, int size);

ArrayHelper(int *valueArray, int size);

double getMax();

double getMin();

double getAverage();  

};

#endif

//ArrayHelper.cpp

#include "ArrayHelper.h"

#include <iostream>

#include <string>

using namespace std;

ArrayHelper::ArrayHelper(double *valueArray, int size1){

this->size = size1;

Array = new double [size];

for(int i = 0 ; i< size; i++){

Array[i] = valueArray[i];

}

}

ArrayHelper::ArrayHelper(int *valueArray, int size1){

this->size = size1;

Array = new double [size];

for(int i = 0 ; i< size; i++){

Array[i] = valueArray[i];

}

}

double ArrayHelper::getMax(){

double max = 0;

if (size <= 0){

return max;

}

max = Array[0];

for (int i =0 ; i < size; i++){

if (max < Array[i]){

max = Array[i];

}

  

}

  

return max;

}

double ArrayHelper::getMin(){

double min = 0;

if (size <= 0){

return min;

}

min = Array[0];

for (int i =0 ; i < size; i++){

if (min > Array[i]){

min = Array[i];

}

  

}

  

return min;

}

double ArrayHelper::getAverage(){

double avg = 0;

double sum = 0;

if (size <= 0){

return avg;

}

for (int i =0 ; i < size; i++){

  

sum += Array[i];

// cout << "sum is " << sum << "Array is " << Array[i];

  

  

}

// cout << "val " << (sum/size) <<endl;

return (sum/size);

}

// driver.cpp

#include "DogHealth.h"

#include "ArrayHelper.h"

#include <iostream>

#include <string>

using namespace std;

int main(){

DogHealth dog_object;

dog_object.printDogHealth();

dog_object.printWeightStatistics();  

dog_object.printHeartRateStatistics();

// g++ -o d DogDriver.cpp DogHealth.cpp DogHealth.h ArrayHelper.h ArrayHelper.cpp

  

}

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