hw8.cpp

// Programmer: Jennifer Leopold date: November 5, 2014

// File: hw8.cpp

// Purpose: This program compares the prompts the user

// to enter a complaint about a medical condition.

// It then makes a diagnosis of their problem based

// on which body part they mention in their complaint,

// generates a prescription for medications, and may

// recommend a surgical procedure. Data for these

// decisions are read from text files.

//

// To compile: fg++ hw8.cpp hw8fncts.cpp -o hw8

//

// To execute: ./hw8

#include <iostream>

#include <fstream>

#include <sstream>

#include <cstdlib>

#include <ctime>

#include <string.h>

#include "hw8.h"

using namespace std;

int main()

{

bool invalidAnswer; // for processing next patient

char anotherPatientYN;

string complaintWords[MAX_COMPLAINT_WORDS];

short numWordsInComplaint;

string whichBodyPart; // "hand", "leg" etc.

bool bodyPartMentioned; // false if no body part mentioned

// Seed the random number generator

srand(time(NULL));

// Process each patient (as long as there are patients)

do

{

bodyPartMentioned =

getHealthComplaint(complaintWords, numWordsInComplaint,

whichBodyPart);

respondToComplaint(complaintWords, numWordsInComplaint);

if (!bodyPartMentioned)

cout << "\nYou clearly have no real complaint.\n"

<< "Take two aspirin and get some sleep.\n";

else decideDiagnosis(whichBodyPart);

recommendPrescription(numWordsInComplaint);

decideOnSurgery();

do

{

cout << "\nIs there another patient? (y/n) ";

cin >> anotherPatientYN;

// Eat '\n' for upcoming getline's

cin.ignore(NUM_CHARS_TO_IGNORE_UNTIL_NEWLINE, '\n');

invalidAnswer = (anotherPatientYN != 'y') &&

(anotherPatientYN != 'n');

if (invalidAnswer)

cout << "Invalid input!\n";

} while (invalidAnswer);

} while (anotherPatientYN == 'y');

cout << "\nThe office is now closed.\n";

return 0;

}