1002 Majed Sameer 18 .6 18 .2 2 Press Enter key to continue . . . Please select your choice: 2 Enter Patient ID: 1552 Error: Invalid Patient Press Enter key to continue . . . Option 3: Display all Patient Weight It prompts for- and reads a maximum weight from the user. Then it displays all patients with weight less than or equal to the give weight. Also, it displays the percentage weight increase (with a + sign) or decrease (with a - sign) in the patients weight from the average weight, using the formula in Eqn (1) below: P = (weight – average weight)/ (average weight) x 100 ……………………………… (1) Please select your choice: 3 Please enter max. weight (Kg): 55 Patient ID Patient Name Weig
read the pictures first then this is the remaining of the question.
Option 2: Display the Record of a particular Patient
When a user selects option 2, The main function prompts for and reads a PatientID. Then it calls the the
function getPatient(patientID), which then searches for this PatientID in the text-file. If the Patient is not
found, an appropriate error message is displayed, otherwise; the Patient’s information is displayed. In
both cases, the option waits for the Enter key to be pressed before returning control to the main menu.
Please select your choice: 2
Enter Patient ID: 1002
Patient ID Patient Name Weight Ave. Weight Visits
1002 Majed Sameer 18 .6 18 .2 2
Press Enter key to continue . . .
Please select your choice: 2
Enter Patient ID: 1552
Error: Invalid Patient
Press Enter key to continue . . .
Option 3: Display all Patient Weight
It prompts for- and reads a maximum weight from the user. Then it displays all patients with weight less
than or equal to the give weight. Also, it displays the percentage weight increase (with a + sign) or
decrease (with a - sign) in the patients weight from the average weight, using the formula in Eqn (1)
below:
P = (weight – average weight)/ (average weight) x 100 ……………………………… (1)
Please select your choice: 3
Please enter max. weight (Kg): 55
Patient ID Patient Name Weight Ave. Weight P(%) Visits
1007 Ahmad Said 51.5 51.5 0.00 1
1003 Suleiman Wasim 25.5 28.5 -10.53 2
1002 Majed Sameer 18 .6 15 .2 +22.37 2
1001 Aisha Abdullatif 10.1 10.1 0.00 1
Press Enter key to continue . . .
Please select your choice: 3
Please enter max. weight (Kg): - 55
Error: Invalid withdraw amount
Press Enter key to continue . . .
Option 4. Update Patient
This option uses the function update(patientID, weight). It prompts for and reads a PatientID, and their
current weight (weight). The new average weight can be calculated using Eqn (2) and the new visit
counts can be calculated using Eqn (3).
Ave. weight = (weight + ave. weight * visit) / (visit + 1) …………………………………….. (2)
visit = visit + 1 ………………………………………………………………………...…. (3)
If the PatientID is zero, or the PatientID, visits and/or any of the weights (i.e., weight and average
weight) is negative an appropriate error message is displayed; otherwise it searches for this PatientID in
the text-file and update their record as described earlier. Also, if the PatientID is not found an
appropriate error message is displayed, as shown by the test run below:
Please select your choice: 4
Please enter Patient ID: 1001
Please enter current weight (Kg): 11.15
Please enter average weight (Kg): 10.25
Please enter the patients number of visits: 3
Patient’s information has been updated . . .
Press Enter key to continue . . .
Please select your choice: 4
Please enter Patient ID: 2256
Please enter current weight (Kg): 11.15
Please enter average weight (Kg): 10.25
Please enter the patients number of visits: 3
Error: Invalid patient ID
Press Enter key to continue . . .
Please select your choice: 4
Please enter Patient ID: 1001
Please enter current weight (Kg): -11.15
Please enter average weight (Kg): 10.25
Please enter the patients number of visits: 3
Error: Invalid weight
Press Enter key to continue . . .
Control is returned to the main menu after pressing the Enter key.
Options 5. Add New Patient
To implement Option 5, search the text-file for the PatientID of the record to be added. If the PatientID
exists, display an error; otherwise append the new record to the end of the text-file.
Options 6. Delete Patient
To implement option 6, search the text-file for the PatientID and deleted the patient when found. If the
PatientID does not exist, display an error.
Note:
Use the clause throws FileNotFoundException or throws IOException for each method that
performs File I/O.
You must not share code with another project group. Doing so will result in a zero grade for all
groups involved.
Step by step
Solved in 2 steps
it does not work can u send the file and re write the cade right