Hospital Management System
Algorithm Design Activity
Name: Deja Jarrett
Date: Oct. 26. 2024
Class: Computer Science
Part 1: Algorithm Tracing (Starter Activity)
Instructions: Examine the flowchart for the hospital billing system provided by your
teacher. Trace the flow of the algorithm by answering the following questions:
1. What happens if the patient does not receive medication?
Answer: Bill = payment + treatment
2. How does the algorithm handle the calculation of total payments?
Answer: after the bill is printed, the calculation for total payments is total payments,
which is set at zero added to the bill amount previously printed.
3. What will occur if the input option is neither ‘0’ nor ‘1’?
Answer: the program will accept any value not equal to zero
4. What changes in the algorithm once the user decides to terminate the process?
Answer: the statement terminating program will be shown to user and the program
will stop.
5. A patient has made an upfront payment of $1,000 and received both medication
costing $7,800 and treatment costing $1,220. What will the total bill be, and
how much is still due after the payment?
Answer: the bill will be 10,020, the amount due after the payment 9020
Part 2: Modify the Algorithm (Main Activity 1)
Instructions: Your task is to modify the hospital billing system flowchart to
incorporate a new feature assigned to your group. Adjust the flowchart to include this
feature and write the pseudocode for the updated algorithm.
Feature Assigned: (Your teacher will assign one of the following):
- Handling patient discounts. ( sahara ) – loyalty Discount (5%) & Add TotalPayments
for those who have medication.
- Adjust the way that payment is treated in the algorithm (zachary)
- Allowing payment in installments (24 installments) ( deja )
- Printing the totalpayments value once the program terminates (tian)
- Incorporating insurance coverage.
- Allowing payment in installments (24 installments)
Without medication
Bill = Treatment – Payment
Bill = Bill/24
Print ‘ Monthly
installment
amount’ , Bill
With medication
Bill = (Medication + Treatment) - Payment
Bill = Bill/24
Print ‘ Monthly
installment
amount’ , Bill
Questions:
1. What specific changes did you make to the algorithm’s flow?
- The specific change was the change in calculation of bill and was adding another
program/process of calculating bill amount for each month.
2. How does this new feature affect the calculation of the bill or the loop structure?
- This new feature affects the calculation of the bill because instead of giving the
total bill it gives you the amount of the bill for a monthly payment of two years.
3. How did you handle any new inputs or data required for this feature?
- A new input and process box is added into the program to implement a new feature.
Part 3: Designing the Hospital Management System (Main
Activity 2)
Instructions: The hospital management system you are designing consists of
several core functionalities. Your task is to design the pseudocode and flowcharts for
each functionality. For each section below, write pseudocode and draw a flowchart to
represent how your system will handle each process.
Part 4: Identifying and Correcting Errors (Main Activity 3)
Instructions: Examine the pseudocode below for a hospital billing process. This code
contains both logical errors. Use a trace table to follow the algorithm and identify the
errors.
Faulty Pseudocode:
START
INPUT Patient_ID, Payment
IF Payment < 0
PRINT "Invalid Payment"
END IF
INPUT Total_Cost
IF Payment > Total_Cost
PRINT "Payment is less than required"
ELSE
Total_Cost = Total_Cost - Payment
PRINT "Payment successful"
END IF
END
Trace Table (use to identify errors):
Ste Patient_ID Paymen Total_Cost Error Found (Y/N) Corrected Code (If
p t Needed)
1 BK1 500 700 IF payment >total_cost IF payment < total_cost
PRINT “Payment is less PRINT “Payment is less
than required” than required”
2 BK2 250 1500 No error found No error found
3 BK3 305 500 No error found No error found
Questions:
1. Identify one logical error in the pseudocode and explain how to fix it:
IF Payment > Total_Cost
PRINT "Payment is less than required"
In this part the sign must be changed to less than ‘< ’
Part 5: Reflection (Plenary Activity)
1. How did your algorithm modification affect the overall system flow and efficiency?
2. What was the most challenging part of designing a pseudocode algorithm for the
hospital management system?
3. If you had to optimize your algorithm to handle thousands of patients, what
changes would you make?
Extension Task (Homework):
Write pseudocode for a new feature to track the availability of hospital beds or
emergency room visits. How will this feature integrate with your existing hospital
management system?