Due: Friday, October 17, 2014 at noon 100 pts
For this assignment, you will submit in the not quite so usual way three files containing the header file, main file, and implementation file for the programming project described below. As usual, create a new directory for this new homework assignment, having it contain these three files appropriately named. Remember that the submit script will pick up any files in the current directory (the one in which you issue the cssubmit command) with .h and .cpp extensions (among others you don't need to worry about now). So, submitting will be the same. However in order to compile your program, you need to issue the command (at the unix prompt) fg++ *.cpp -o <your_executable_name>, as discussed in class.
This program will give you practice using
multiple files
functions
pre-, post-, and function descriptions
pass-by-reference parameters as well as pass-by-value parameters
structs
random number generation
Background: Dr. Eloe (doesn't that just ring like Dr. Jeckle! to you?) has been diagnosing Jejunal Hemorrhage Syndrome in his patients for many years using the old methodology of inserting a mechanical probe tipped with a camera into the esophagus to take pictures and retrieve sampling from the stomach linings. He has come upon a new method of determining the presence of this disease and needs your programming acumen to make quicker the interpretation of the gathered data. The method avoids the distasteful insertion of a sterile, flexible medical implement down a person's throat! Yuck! How brutal, uncaring, and insensitive is that?! No, Dr. Eloe will employ new research recently developed by his nurse (Nurse Ward) which is decidedly more patient-friendly. Being holistic and all-natural, using completely organic agents, the patient is assured a safe, comfortable diagnostic plan to discover their fate.
Now, it is also the case in these tests for JHS that on occasion the roach doesn't hear the tone from Eloe's tuning fork due to loud bodily noises. This happens about 5% of times that any tone is rung. In that case, your program should output a message to the effect that "insufficient data collected - proteins pX and pY not represented" or something like that. That should end the testing for that patient.
You should notice also that proteins p1 and p2 and p4 are determinable by two of the tone functions. You should (and it is logical) to use the greater of the two p1 values, and to use the minimum of the two p2 values, and to use the greater of the two p4 values.
Cockroaches have been used in medical research for a long time! Now, Nurse Ward has trained cockroaches to respond to different sounds from a tuning fork. When they hear the note A-flat, they jump up and down. When they hear the note middle-G, they excitedly move their antennae back and forth. When they hear the note C-flat, they vigorously rub their head on whatever surface they can find. It turns out that the cockroach’s legs, antennae, and head have special receptors on which various proteins naturally attach. Sooo, all the patient has to do is swallow a harmless, natural, organic and socially well-adjusted cockaroach with a fishing line attached for retrieval. (Don't worry, the fishing line is also all-natural and custom fit to the roach using an ergonomic harness to minimize harm to the animal.) The doctor simply holds a tuning fork to the stomach of the patient and rings the required tones, knowing that the cockroach is performing his gentle dances within the dark confines of the stomach gathering the necessary information for diagnosis. The doctor "fishes" the roach out of the patient and extracts the proteins for his prognosis. The research has shown:
proteins p1, p2, p3 attach to their legs
proteins p2, p4 attach to their antennae
proteins p1, p4, p5 attach to their head
oatmeal, carrots, and peas stick to their wings, but this isn't important
Also, the research has shown that necessary conditions for the disease to be present in the patient (a positive prognosis) are as follows:
protein p1 must be present in any case
And sufficient conditions for the disease include these:
if protein p5 level is less than 2, then p4 must be between 20 and 40, exclusive, and p3 must be greater than 6; or
if protein p5 level is greater than or equal to 2, then the sum of p1 and p2 and p3 levels must be less than 75; or
protein p2 level less than or equal to 14.6.
Protein "levels" are measured on different scales for the different proteins:
p1 levels fall from 0 to 100, but are only detectable when 10 or above
p2 levels fall in the interval from 0 to 100.0 and can be measured to the nearest tenth.
p3 values are integer values in the interval 0 to 10
p4 values are integers having a minimum of 10 and maximum of 50
p5 values are integer values in the interval 0 to 10
Specifications: Your program is to loop for the determination of the presence of JHS (Jejunal Hemorrhage Syndrome) for multiple patients. Read in the name of the patient each time and terminate the loop in any appropriate manner. For each patient, you will determine the presence/levels of the five proteins and then output a prognosis based on the information above. You are to write this program using functions to make you code simple to understand, easy to maintain, and modifiable. You should have three functions to "acquire" the data from the cockroach for each of the tone tests. Since you don't really have a roach to stuff down a nonexistent patient's throat (oh, wouldn't that be fun!), you are going to simulate the acquisition of protein gathering using the random number generator. For example, you would have a tone1 function that simulates Dr. Eloe ringing his tuning fork to A flat, but what it actually does is generate random values using our random number generator to assign to the p1, p2, and p3 protein levels (according to the information above). The function would then have to send that info back to the calling function. Of course, you would have similar functions for the 2nd and 3rd tones to gather info for the other proteins.
Once all the protein level information is gathered, it is to be "wrapped up" in a struct and passed to a function that will determine whether or not the patient has the dreaded JHS. You will have other functions, no doubt; think modular.
The output for each patient should include not only the prognosis, but also the levels of all the proteins measured.
Don't forget to
make your output user friendly
document your code, specifically your functions
use good variable names, good formatting, constants where applicable
When you submit: During the submission process, run the diagnostics for three patients whose names are your best friends' names (remember: no whitespace).
As usual, don't hesitate to ask for help or see the LEAD tutors if you are having trouble.
Note: The roach to the right is Dr. Eloe's housekeeper.