# c hw 0

You will be creating a person class.  This person class will have the following data ID Number, Name, Height (in feet and inches), and Weight, so FIVE pieces of data.

You will have methods to store the ID, Name, Height (two parameters one for feet, one for inches), and Weight.

Don't use plagiarized sources. Get Your Custom Essay on
Need an answer from similar question? You have just landed to the most confidential, trustful essay writing service to order the paper from.
Just from \$13/Page

You will have methods to return the ID and Name.

You will have methods to calculate the BMI and BMI Classification.

BMI Formula = (pounds*703) / (inches * inches)

BMI Classifications (your method will return Underweight, Normal weight, Overweight, or Obesity)

Underweight = BMI <18.5

Normal weight = BMI between 18.5–24.9

Overweight = BMI between 25–29.9

Obesity = BMI of 30 or greater

Create a normal (non-method function) that will take in two people objects and return a boolean value of TRUE or FALSE.  This function will compare the person’s name in object 1 to the person’s name in object 2, if object1 name is less than object 2 name, return TRUE else you will return FALSE.  This function will be used as the third argument to the standard sort call.  We have to create a function for the sort to use because we are trying to sort class objects that have many variables – the function allows us to define what variables in our class objects gets used in the comparison for sorting (otherwise the sort function wouldn’t know how to sort in our class objects, simple arrays or vectors do not need this function).

Create a people array or vector (your choice) of the person class — if you use an array you will have to set an upper limit on how many people can be entered like 100 or some value like that.

The flow of your program will be:

• Ask for Name, store in your people array/vector person object – use the following code to make sure the keyboard buffer is clear before reading in your name string from the keyboard (previous ID question can leave newline character on the buffer)
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), ‘n’);
getline(cin,name);

• Ask for Height (feet and inches), store in your people array/vector person object

• Keep repeating these previous steps of asking and storing the values into new people array elements or new vectors elements of your person object until ID = -1 (or less than 0)

• Now sort based on person object name in your people array or vector, review syntax for sort from 10/26 (arrays) and 10/28 (vectors) lectures, with the name of your “normal” sort helper function you created before as your third argument to the sort call.

• Now loop through your array or vector and do the following

• Print ID

• Print Name

• Print BMI

• Print BMI Classification

Remember to write this in baby steps compiling a little bit at a time – do not try to write all the methods at once and run it, it is much easier to troubleshoot by adding only a few lines of code and compile to see how that works.  For example on this program – write the ID methods first, do not write any other methods until you get the ID methods working for storing and returning the ID – write the storing one first make you get no errors then write the return method next verifying the store method worked.  Once that is working, create the Name methods using the same way. etc.  Once all your methods work correctly with one person, create your array or vector of many people, etc.  Lastly sort your array or vector.  You build this up slowly is much easier to troubleshoot — add a few (1-9) lines not 10’s/100’s of lines before you compile and check what you just added, if you have a problem it is most likely in those last few lines of code you just added/changed.

Example program run:

This program will ask for a group of people’s ID#, Name, Height, and Weight – after entering everyone in a report will be shown, showing each person BMI and classification.

Please enter ID (-1 to quit) = 55

Please enter Name : Job B.

Please enter height (feet and inches) : 6 0

Please enter weight in pounds : 245

Please enter ID (-1 to quit) = 45

Please enter Name : Frank G.

Please enter height (feet and inches) : 5 9

Please enter weight in pounds : 175

Please enter ID (-1 to quit) = 23

Please enter Name : Linda Q.

Please enter height (feet and inches) : 5 4

Please enter weight in pounds : 142

Please enter ID (-1 to quit) = 88

Please enter Name : Anna L.

Please enter height (feet and inches) : 6 2

Please enter weight in pounds : 138

Please enter ID (-1 to quit) = -1

Person  #: 88

Name: Anna L.

BMI: 17.7162

Classification: Underweight

Person  #: 45

Name: Frank G.

BMI: 25.8402

Classification: Overweight

Person  #: 55

Name: Job B.

BMI: 33.2243

Classification: Obese

Person  #: 23

Name: Linda Q.

BMI: 24.3716

Classification: Normal Weight