Assignment 05

Due: Wednesday, Oct. 8, 2014 at noon 100 pts

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Of course, you will submit in the usual (correct) way.

Background: Well, Dr. Eloe is very happy with your programming skills so far! Now he needs your help once again. He has trouble remembering how to determine all those pesky functions of good health, such as heart rate, blood pressure, TMI, BMI, HDL, LDL, IQ, belt size, etc. Sooo, he's wanting you to program up a "calculator" of sorts. He could use this device (your program) in his practice to quickly calculate indicators of bodily fitness (such as the above) as he gathers information (heart rate, blood pressure, hair length, etc) from his patients.

In this program, you are to use functions to accomplish many tasks. The functions you are to include are hereby described:

  1. a function called greeting whose sole purpose is to display to the user some kind of greeting. It has no parameters and returns nothing.

  2. a function called bodyMassIndex that has two integer parameters (clearly, one for weight and one for height), and it returns a float, BMI, as calculated by the formula below.

  3. a function called creatinineClearance to which is passed two integers (age and weight) and a float (serum creatine value), and which returns a float.

  4. a function called coronaryRisk that has three parameters: a float for BMI, a boolean for genetic predisposition to heart disease, and short for the number of lbs of bacon the user has eaten for breakfast. This function will calculate the CR according to the formula below and return that value.

  5. a function called totterIndex to which is passed two floats, and that returns a float determined by the formula below.

  6. a goodbye function that merely outputs a sign-off message.

You must understand that there are many ways to code this assignment. You may want to include other functions, but you are required to include the functions described above. You should clearly include a loop on a presentation of a menu and a switch-case to handle the choices. For each case, your code should gather the information from the user and then pass it to the appropriate function. The return value is then output. However, in the case of the CR, the information is gathered by the function. Thus, pseudo-code for the program might look like this:

begin main

declare variables

greeting

loop

present menu

switch on choice

case 1

input info from user

bmi = bodyMassIndes(info)

output bmi

case 2

input info from user

cc = creatinineClearance(info)

output cc

case 3

input info from user

cr = coronaryRisk(info)

output cr

etc

More details:

The way to calculate the BMI, CC, CR and TI are here given:

  • BMI is calculated as [ mass (lbs)/(height (in))2 ] x 703

  • CC is give by ( 140 - age(in yrs) ) * wt(in kg) / 72 * (serum creatine)

  • CR is calculated to be the sum of responses to the following survey:

BMI > 30: yes 2 no 0

either parent have heart disease: yes 1 no 0

1 point for every pound of bacon for breakfast this morning.

  • TI is calculated thusly: (length of left leg / length of right leg) note: if either length is 0, then TI is 0.

Input the necessary information from the user only when it is required. The output of the calculated values should be only that (e.g. BMI is 34.4). There need not be any interpretation of the values by your calculator. For example, TI output might be .85, but your code does not need to output any medical (or otherwise) recommendation based on that value. It should simply state what the value is.

When you submit: As usual, you will run your program when submitting. Enter the following values.

  1. option 1; enter 260 for wt and 52 for ht

  2. option 2; enter age 70, 50 kg, and 6.3 for serum

  3. option 3; enter 55, yes, and 3. (It'll probably be the last time you get to eat 3 lbs of bacon for breakfast)

  4. option 4; enter 36 for left leg, 0 for right leg.

  5. quit

As usual, if you have any questions, ask your instructor or the LEAD guys.

1This is a real and helpful index that gives some indication of your "thickness" or "thinness", helping you to understand your health better.

2I have no idea what this is, but it's scientific ... and doctors swear by it.

3Pretty much, I made this up.

4Ficticious nonsense....but maybe useful.

5Probably the best choice in this menu.

Details:

1. Body Mass Index (BMI)1

2. Creatinine Clearance (CC)2

3. Coronary Risk (CR)3

4. Totter Index (TI)4

5. Quit5

Eloe's Health-o-matic

Specifications: Your program will once again be menu driven with the following choices of information to calculate: