// Programmer: Jennifer Leopold date: September 25, 2014
// File: hw5.cpp
// Purpose: This program will calculate various health
// functions as selected from a menu.
//
// To compile: fg++ hw5.cpp hw5fncts.cpp -o hw5
//
// To execute: ./hw5
#include <iostream>
#include "hw5.h"
using namespace std;
int main()
{
bool invalidSelection; // true when invalid menu selection
short menuChoice; // user's selection from menu
float serumCreatine, // the various attributes of a user
leftLegLength, // that may need to be input to
rightLegLength, // calculate a health function
bodyMassIndexValue;
short height, weight,
age,
poundsBaconEaten;
bool heartDiseasePredisposition;
// Greet user
greet();
// Display menu and perform desired functionality until
// user wants to quit
do
{
cout << "1. Body Mass Index (BMI)\n";
cout << "2. Creatinine Clearance (CC)\n";
cout << "3. Coronary Risk (CR)\n";
cout << "4. Totter Index (TI)\n";
cout << "5. Quit\n";
// Loop until user makes valid selection
do
{
cout << "Please enter selection (1-5): ";
cin >> menuChoice;
invalidSelection = (menuChoice < 1) || (menuChoice > 5);
if (invalidSelection)
cout << "Invalid selection!\n";
} while (invalidSelection);
// Perform corresponding calculation
switch (menuChoice)
{
case 1: height = promptForNonNegativeShort("height (in)");
weight = promptForNonNegativeShort("weight (lbs)");
cout << "Body mass index = "
<< bodyMassIndex(weight, height) << endl;
break;
case 2: age = promptForNonNegativeShort("age (yrs)");
weight = promptForNonNegativeShort("weight (kg)");
serumCreatine = promptForNonNegativeFloat
("serum creatine value");
cout << "Creatinine clearance = "
<< creatineClearance(age, weight,
serumCreatine)
<< endl;
break;
case 3: bodyMassIndexValue = promptForNonNegativeFloat
("BMI");
heartDiseasePredisposition =
promptForBool("heart disease predisposition");
poundsBaconEaten = promptForNonNegativeOrZeroShort
("pounds of bacon eaten");
cout << "Coronary risk = "
<< coronaryRisk(bodyMassIndexValue,
heartDiseasePredisposition,
poundsBaconEaten)
<< endl;
break;
case 4: leftLegLength = promptForNonNegativeOrZeroFloat
("left leg length (in)");
rightLegLength = promptForNonNegativeOrZeroFloat
("right leg length (in)");
cout << "Totter index = "
<< totterIndex(leftLegLength,
rightLegLength)
<< endl;
}
cout << endl;
} while (menuChoice != 5);
// Sign off
goodbye();
return 0;
}