Question
For this homework, you will develop a very simple Medical Diagnosis System to aid a clinic in determining whether a patient is healthy or suffering
For this homework, you will develop a very simple Medical Diagnosis System to aid a clinic in determining whether a patient is healthy or suffering from a cold, the flu, the measles, the mumps, or if the diagnosis is uncertain. You will base your diagnosis on the chart below. Combinations of symptoms that do not fit any of the categories shown below will result in a diagnosis of Uncertain. Patients with a diagnosis of Measles, Mumps, or Uncertain will be asked to reschedule a follow-up appointment in 3 days.
Diagnosis | Body Temperature | Congestion | Aches | Rash | Swelling |
---|---|---|---|---|---|
Healthy | less than 99 | no | no | no | no |
Cold | less than 100 | yes | no | no | no |
Flu | 100 or greater | no | yes | no | no |
Measles | 100 or greater | no | no | yes | no |
Mumps | 100 or greater | no | yes | no | yes |
For this project, you will write a program named DiagnosisSystem.java It must display a header that lists the name of the application you may name it as you like and provides instructions about using the program. For example,
Welcome to the Diagnosis Decision Support System When prompted, please enter today's month and day (e.g., 3 14), the patient's full name, temperature, and whether the patient is experiencing congestion, aches, a rash, and/or (salivary gland) swelling. A diagnosis of Healthy, Cold, Flu, Measles, Mumps or Uncertain will be output as well as a return date, if the diagnosis is Measles, Mumps or Uncertain.
The user should be prompted for the following input values:
Patient (name) - Input as a String.
Month - Input as an integer.
Day - Input as an integer.
Temperature - Input as a double.
Congestion (y/n) - Input that starts with y or Y should be considered as yes, any other input should be considered as no.
Aches (y/n) - Input that starts with y or Y should be considered as yes, any other input should be considered as no.
Rash (y/n) - Input that starts with y or Y should be considered as yes, any other input should be considered as no.
Swelling (y/n) - Input that starts with y or Y should be considered as yes, any other input should be considered as no.
You may assume the month and day occur during the year 2018.
The program should then output the patients name, the date (with 2018 as the year), the diagnosis, and the reschedule date (3 days after the date if the diagnosis is Measles, Mumps, or Uncertain, None otherwise assume the clinic is open 7 days a week) as shown below.
Here are some examples:
csc$ java -cp bin DiagnosisSystem Welcome to the Diagnosis Decision Support System When prompted, please enter today's month and day (e.g., 3 14), the patient's full name, temperature, and whether the patient is experiencing congestion, aches, a rash, and/or (salivary gland) swelling. A diagnosis of Healthy, Cold, Flu, Measles, Mumps or Uncertain will be output as well as a return date, if the diagnosis is Measles, Mumps or Uncertain. Patient: Mary Kay Jones Month Day (e.g., 3 14): 3 10 Temperature: 102.3 Congestion (y,n): y Aches (y,n): n Rash (y,n): y Swelling (y,n): n Patient: Mary Kay Jones Date: 3/10/2018 Diagnosis: Uncertain Return Date: 3/13/2018
csc$ java -cp bin DiagnosisSystem Welcome to the Diagnosis Decision Support System When prompted, please enter today's month and day (e.g., 3 14), the patient's full name, temperature, and whether the patient is experiencing congestion, aches, a rash, and/or (salivary gland) swelling. A diagnosis of Healthy, Cold, Flu, Measles, Mumps or Uncertain will be output as well as a return date, if the diagnosis is Measles, Mumps or Uncertain. Patient: Mark Smith Month Day (e.g., 3 14): 12 30 Temperature: 101 Congestion (y,n): yep Aches (y,n): uncertain Rash (y,n): yes Swelling (y,n): dontknow Patient: Mark Smith Date: 12/30/2018 Diagnosis: Uncertain Return Date: 1/2/2019
csc$ java -cp bin DiagnosisSystem Welcome to the Diagnosis Decision Support System When prompted, please enter today's month and day (e.g., 3 14), the patient's full name, temperature, and whether the patient is experiencing congestion, aches, a rash, and/or (salivary gland) swelling. A diagnosis of Healthy, Cold, Flu, Measles, Mumps or Uncertain will be output as well as a return date, if the diagnosis is Measles, Mumps or Uncertain. Patient: Julia Ann Thomas Month Day (e.g., 3 14): 4 21 Temperature: 99.7 Congestion (y,n): y Aches (y,n): no Rash (y,n): no Swelling (y,n): no Patient: Julia Ann Thomas Date: 4/21/2018 Diagnosis: Cold Return Date: None
Input/Error Handling
If the user enters an invalid date, the program should print an error message as soon as the error occurs and quit. HINT: The statement System.exit(1); will cause the program to quit with a status of 1 indicating an error condition. NOTE: You do not need to handle the situation where the user enters something other than an integer for the month or day, or something other than a double for temperature. We will learn to handle this later in the semester.
Here are some examples of handling invalid input:
csc$ java -cp bin DiagnosisSystem Welcome to the Diagnosis Decision Support System When prompted, please enter today's month and day (e.g., 3 14), the patient's full name, temperature, and whether the patient is experiencing congestion, aches, a rash, and/or (salivary gland) swelling. A diagnosis of Healthy, Cold, Flu, Measles, Mumps or Uncertain will be output as well as a return date, if the diagnosis is Measles, Mumps or Uncertain. Patient: Anne Green Month Day (e.g., 3 14): 3 35 Invalid date
csc$ java -cp bin DiagnosisSystem Welcome to the Diagnosis Decision Support System When prompted, please enter today's month and day (e.g., 3 14), the patient's full name, temperature, and whether the patient is experiencing congestion, aches, a rash, and/or (salivary gland) swelling. A diagnosis of Healthy, Cold, Flu, Measles, Mumps or Uncertain will be output as well as a return date, if the diagnosis is Measles, Mumps or Uncertain. Patient: David Brown Month Day (e.g., 3 14): 4 31 Invalid date
csc$ java -cp bin DiagnosisSystem Welcome to the Diagnosis Decision Support System When prompted, please enter today's month and day (e.g., 3 14), the patient's full name, temperature, and whether the patient is experiencing congestion, aches, a rash, and/or (salivary gland) swelling. A diagnosis of Healthy, Cold, Flu, Measles, Mumps or Uncertain will be output as well as a return date, if the diagnosis is Measles, Mumps or Uncertain. Patient: John Black Month Day (e.g., 3 14): 14 10 Invalid date
The program must contain and use the completed version of the methods below. You are free to (and encouraged to) define and use additional methods, if you like be sure to provide Javadoc for them.
//Return true if the date is a valid date during 2018 //Return false otherwise public static boolean isValidDate(int month, int day) { }
//Determine and return the diagnosis (Healthy, Cold, Flu, Measles, Mumps, Uncertain) //based on a patient's symptoms and the chart given above public static String getDiagnosis(double temperature, boolean congestion, boolean aches, boolean rash, boolean swelling) { }
//Throw an IllegalArgumentException with the message, "Invalid date", if the //month and day do not represent a valid date in 2018 //Return a date formatted as month/day/year, e.g., 12/9/2018, that occurs //3 days after the given month and day in 2018 public static String getReturnDate(int month, int day) { }
Please note that your program should NEVER call the getReturnDate() method with illegal arguments because you should do thorough error checking BEFORE calling the method! This requirement is simply to give you practice in checking method parameters and throwing exceptions. It is good practice to include a helpful/descriptive message when you throw an exception. For this project, it is required that you include the message Invalid date with each IllegalArgumentException you throw.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started