Assignment 08

Due: Wednesday, November 12, 2014 at noon 100 points

Instructions: You know how to submit; do it in the usual way. You will submit multiple files for this programming project. The cssubmit script will work as usual, picking up all .cpp and .h files in the current directory. So, make sure you have created a separate directory for your hw 8 program. (Do not create sub-directories in the hw8 directory.)

Background: The good doctor (yes, we're speaking of Doc Eloe) is getting tired of writing prescriptions for his patients. Besides, no one can really read them anyway. In fact, Dr. Eloe is tired of doing almost all of his job. And so, he wishes you to automate most of the doctor-patient experience for him. He wants you to code a program that will run on a console that sits in the entryway of his medical offices. It will greet the patients, ask what ails them, then dispense a prognosis, a prescription, and even a possible appointment for surgery. How cool is that?! Doc Eloe can then spend his waning professional days hunting big game on safari, playing golf or tennis, or even playing in a crappy rock band full of aging hippies. He'll only come back to town to collect his paycheck. Wow! Now that's progress. Of course, the weakness in his game is that he won't be present when the patient registers his/her complaint, so the prognosis, diagnosis, prescriptions, and surgical recommendations will all have to be generated at random. (This should be fun.)

Specifications: Your program is to prompt the user to input a health complaint; prose of any length up to 100 words. (You may assume no word is longer than 20 characters.) The prompt will inform the user that the complaint (symptoms of what ails them) must contain one of the following words: head, torso, hand, nose, or leg. The reason for this is simply because Doctor Eloe slept through most of his medical training and only picked up these 5 "vocabulary" words. He doesn't actually know what they mean, but that won't matter. Your program searches the input for these words. Finding one, your program will use it to access a data file whose name is that word (with ".dat" appended, such as "head.dat", "hand.dat", "leg.dat", etc.) in which there are prognoses for your program to choose from at random! You will create these data files, and you may put, as the first data element in the file, the number of prognoses in that file. (Each prognosis will be on its own line. See files below.) The prognosis randomly chosen is displayed as part of the output. Also, your program will choose at random n/2 words (not to exceed 5), where n is the number of words in the patient's complaint, taken from the patient's initial complaint and output them in the following format:

"So, word1 word2 ... word5?" end it with a '?'

The reason for doing this is to assure the patient that Dr. Eloe is indeed listening to their complaint, so that they know he cares and will give them well-informed, expedient and helpful advice. Don't worry that this output won't make any sense whatsoever; no one ever reads anything official anyway.

Next, your program will use another data file, "scripts.dat", to generate a prescription drug name...at random, of course! The file will contain a list of syllables taken from common drug names. Your code is to pick 4 of these syllables at random and stick them together to form the name of a drug (isn't that what the drug companies do?). That prescription will also be part of the output of the program.

Also, your program will use the number of words in the complainer's patient's complaint to establish the "strength" of the prescription. That is, the number of words will be the number of pills the patient will be instructed to take each day. We'll just standardize the pill strength to 20 mg. of whatever the good doctor invents prescribes. (The way Dr. Eloe figures it, the more wordy the patient is, the more drugs he/she obviously needs....to shut them up.)

Finally, since surveys have shown that 75% of the people who enter a doctor's office end up having one surgery or another, your program will, 75% of the time, choose a recommended surgery from the file "surgeries.dat" and urge the patient to seek that surgery to ameliorate their symptoms.

After this last output, the program should prompt for another.

To review, your output is to include in the following order

  1. "So, word word word...?"

  2. A randomly chosen prognosis

  3. A prescription and the number of pills per day to take

  4. A recommended surgery (75 % of the time)

Here is some sample output:

--------------------------- Dr. Eloe's Health-o-Mattock-----------------------

What is your issue: High Doc. I'm here because I have a terrible pain in my torso. I'm having trouble breathing.

So, here have my I'm breathing? It is clear that you have tuberculosis.

Your prescription is to take 17 pills a day of 20 mg. Azmonidefeneium.

I would also recommend that you undergo a lobotomy.

Nextttt!!??

Special Notes:

  • You are required to use null-terminated character arrays in this assignment for the input and output. However, you may use string variables for file names if you wish.

  • You may have as the first entry in the prognoses and surgeries files the number of data elements in the file. BUT for the syllables file, you may NOT have the first entry be the number of syllables; only syllables are to be in the file. And, you can add your own syllables....if you have some.

  • For this assignment, you may work in a team of two persons. It is assumed that you both will code and that not one of you will sponge off the other. Both teammates will contribute to both code and documentation. Submit under only one name, but make sure that both teammates' names are in the comment headers. Work only with someone who has the same instructor. We encourage you to work together with someone; this is not an easy assignment!

  • There are two possibilities for the key words (torso, head, etc) in the complaint. One is that there are multiple instances. If so, use the first. (If you want to make your program more interesting, code to handle multiple instances in any way you like. If you do, put a big comment in your code explaining this to the grader so he knows what you are doing.) The second possibility is that no instance occurs. If so, your program should output this “default” prognosis: “You clearly have no real complaint. Take two aspirin and get some sleep.” ...and then prescribe drugs and suggest surgery as before.

When you submit: Run the doctor's "work" twice and then quit.

Files:

Important: DO NOT copy and paste this info. Type the data into your files as you would any other information. If you copy and paste, you will pick up spurious, unwanted, ne devious! hidden characters that will make your program and your heart break. Then you will live in misery the rest of your days.....and have to seek help from Dr. Eloe's Health-o-Matic machine.

Leg.dat Head.dat Torso.dat Hand.dat Nose.dat

10 10 10 10 8

Zombie-walk Chin splints Stomach Ache Coding Cramps nose bleed

Rickets Concussion Bellybutton Inversion Too many fingers Runny-nose syndrome

Weird Little Foot Fingers Too many teeth BBQ'd Ribs "Michael Jackson Glove" Clownitis

Leg Crumpets Bad dandruff Spare Ribs Handyman Syndrome Logded-Crayon Syndrome

Tired Leg Syndrome Jello-brain (with broccoli) Cheeseburgeritis Dupuytren's Syndrome Pinocchio Syndrome

Nail-Toe Contentedness Missing Appendix Claw Hand Elephant Trunk Syndrome

Paul's Bunion Syndrome Goofy Ears Heartburn Carpal tunnel syndrome Snotty Kid Syndrome

Frog Legs Cranial Stiffness Tuberculosis Tendenitis Impacted Boogers

Sea Legs Picasso Painting Syndrome Spinal Tap Hand-in-mouth Disease

Severe Totter Syndrome Outgrown Hairs Heart Disease dirty hands

scripts.dat surgeries.dat

asper sim prim 15

butrin famo orac lobotomy

asper dicto tene triple by-pass

oxin dex vu blepharoplasty

heli fabux dine appendectomy

dac stat strabismus

trol hemo thyroidectomy

orol mate tooth extraction

ium faz cataract removal

gam clo spine amputation

arin ta liver biopsy

hepa fil earlobe removal

hex nex haircut

alin prost jejunostomy

hydra taco phlebotomy

hypo rac liposuction