The task in this homework is to implement and design the Medical Assistant programming project described at the end of chapter 5 (section 5.14, pages 235-238). HOWEVER, we are using a modified flowchart, shown at the bottom of this page.
Download the file FeverDiagnosis.java. This will be the one file you submit. Your code will be added to constructor at the end of this file. You will also need the Scanner.class file.
If the user selects y/y/n/y as the input (for questions about fever, coughing, wheezing, and headache, respectively), the program will output the following:
Symptoms: * fever * coughing * headache Diagnosis Possibilities include viral infection
Another example of a sample run is given in the textbook.
The following variables are defined in the file:
Scanner stdin: The Scanner object used to read input from the user. There is no need to modify (or access) this object directly - that is done by the various methods.
String symptoms: This variable holds the symptoms encountered so far. It is modified by the addSymptom() method, and printed via the displayDiagnosis() method. There is no need to modify this variable directly.
Symptom constants (12): These are the symptom constants to be used to print the symptom questions.
Diagnosis constants (8): These are the diagnosis constants to be used to print the final diagnosis.
The following methods are defined in the file
boolean have(String s): Asks whether the user has symptom s.
boolean are(String s): Asks whether the user has symptom s. The difference between are() and have() is how the prompt is phrased. You should use the appropriate method call for the appropriate question (i.e., "Are you coughing", not "Do you have a coughing").
void displayLegend(): Displays the legend at the beginning of the program (called from the constructor, below).
void displayDiagnosis(String diagnosis): If a definitive diagnosis is reached, this method is called to end the program.
void displayUnsure(): If no definitive diagnosis is determined, this method is called to end the program.
void addSymptom(String s): Adds a symptom to the list of symptoms encountered so far.
FeverDiagnosis(): The constructor, this is where your code goes. This should be the ONLY method that is modified. The if-else-if clauses, which make up the flow of control for this program, go in this method.
main(): This method creates a new FeverDiagnosis object, and in doing so, calls the constructor, which executes the diagnosis code.