Solved–Program for entering in a dog’s monthly weight and heart rate —- PROGRAM 2– Solution

$35.00 $24.00

WHAT SHOULD THIS PROGRAM DO? This is a program for entering in a dog’s monthly weight and heart rate (for 12 months) and then printing out statistics. This assignment will allow you to practice creating a makefile and class template. FILES This program contains multiple files as described below Driver.cpp – this is the only…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (3 votes)

WHAT SHOULD THIS PROGRAM DO?

This is a program for entering in a dog’s monthly weight and heart rate (for 12 months) and then printing out statistics. This assignment will allow you to practice creating a makefile and class template.

FILES

This program contains multiple files as described below

  • Driver.cpp – this is the only source file that is provided for you. Do not modify this file. Your code should work with this driver.

  • ArrayHelper.h – class specification for the ArrayHelper class template

  • ArrayHelper.cpp – class implementation for the ArrayHelper class template

  • DogHealth.h – class specification for the DogHealth class

  • DogHealth.cpp – class implementation for the DogHealth class

  • Makefile – makefile to compile & run the program

  • RUN.bat – this is the batch file, which is provided for you and shouldn’t be changed

  • TEST_CASE.txt – this is the test case similar to one that I will use to grade your program. You shouldn’t have to change it to make your program work.

PROGRAM SPECIFICATIONS (DIRECTIONS ON HOW TO WRITE THE PROGRAM)

ARRAYHELPER CLASS TEMPLATE

Create a class specification (ArrayHelper.h) & class implementation (ArrayHelper.cpp) file for a class template named ArrayHelper.

The purpose of the ArrayHelper template class is to perform common array functions on any numerical data type.

ArrayHelper should have the following attributes:

  • A pointer to an array of the template type

  • An integer containing the number of elements in the array

ArrayHelper should have the following member functions:

  • Constructor, which accepts a pointer to an array and an integer containing the number of elements in the array. The constructor should set the number of elements attribute to the number sent to this function. Then, the constructor should create a dynamically allocated array of the same size and then copy the array elements from the array parameter into the ArrayHelper object’s array.

  • Destructor – should release the dynamically allocated array

  • getMax function – should find the largest number in the array and return the integer index of the element that contains the largest number.

  • getMin function – should find the smallest number in the array and return the integer index of the element that contains the smallest number.

  • getTotal function – should find the total of all the elements and return the total

  • getAvg function – should find the average of all the elements (hint: you can call the getTotal function!)

DOGHEALTH

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)

DogHealth 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 dynamically allocated 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 dynamically allocated 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 month that the dog had the highest resting heart rate and the resting heart rate amount o month that the dog had the lowest resting heart rate and the resting heart rate amount o the average resting heart rate of all the months

MAKEFILE

Create a makefile that will compile the program. Remember that you can’t compile the template class because it automatically gets compiled when a template class object gets created. Name your executable file DogHealth.exe.

READABILITY OF OUTPUT & CODE DOCUMENTATION

  • Make sure that your output looks similar to my sample output (below). When I run your program, it shouldn’t make me want to scream. It should be extremely readable and user-friendly.

  • Place a comment block (multi-line comment) above every function in DogHealth.h & ArrayHelper.h describing the function name, parameters, return data, and purpose of the function.

  • Place a comment block at the top of ALL .h and .cpp files that states the filename, your name, and date.

  • Put helpful comments throughout the function definitions where you think there needs to be some explanation of the code.

WHAT TO TURN IN

Zip ALL the files required to compile & run the program, (including the files I provided for you) in a single zipped file named whatever you want. Then, upload this zip file to the assignment folder in ilearn. I will remove one point if you turn in unzipped files.

SAMPLE OUTPUT