Assignment 08

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 Dr. Nick 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 download these data files from us using the method stated below. Note: in each file, the number of prognoses in that file is the first data element in each file. For each file, each prognosis will be on its own line. 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:

Due: Friday, Nov. 1, 2019 at noon 100 points

For this assignment ... 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 Dr. Nick Riviera...the word "good" has different meaning for different people) is getting tired of writing prescriptions for his patients. Besides, no one can really read them anyway. In fact, Dr. Nick 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?! Dr. Nick 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 (see picture to the right). 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.)

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:

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

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

The reason for doing this is to assure the patient that Dr. Nick 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. Nick 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. (Also, this file's first datum is the number of data to follow.)

Nextttt!!??

I would also recommend that you undergo a lobotomy.

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

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

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

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

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 (only) if you wish.

  • For the scripts/syllables file, you may NOT have the first entry be the number of syllables in that file; only syllables are to be in the file. Further, you canNOT hard code that number into your program. And, you can add your own syllables....if you have some.

  • This is not an easy assignment! ...get started early

  • There are three possibilities for the key words (torso, head, etc) in the complaint. One is that there is a single instance, and you know what to do. Another 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 third 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.

  • You can assume no word used is more than 20 characters. You can assume no line in a data file is more than 100 characters.

The data file: To make life simple for you, we have created the files for you so you don't have to worry about typing them in correctly; many people don't. So, you will download them. Create the directory where you are going to make your hw8 program, and then change to that directory. Then, at the unix prompt, type

  • wget http://web.mst.edu/~price/1570/torso.dat

  • wget http://web.mst.edu/~price/1570/leg.dat

  • wget http://web.mst.edu/~price/1570/nose.dat

  • wget http://web.mst.edu/~price/1570/hand.dat

  • wget http://web.mst.edu/~price/1570/head.dat

  • wget http://web.mst.edu/~price/1570/scripts.dat

  • wget http://web.mst.edu/~price/1570/surgeries.dat

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