here's an example implementation of the program in Python
class PatientAccount:
def __init__(self, name):
self.name = name
self.days_spent = 0
self.charges = 0
def surgery(self, surgery_type, cost):
self.charges += cost
print(f"{surgery_type} surgery added to charges.")
def pharmacy(self, medication_type, cost):
self.charges += cost
print(f"{medication_type} medication added to charges.")
def dayCharge(self):
self.days_spent += 1
print("Day charge added.")
def setName(self, name):
self.name = name
print(f"Name set to {name}.")
def getTotalCharges(self):
total_charges = self.days_spent * 1000 + self.charges
print(f"Total charges: ${total_charges}")
return total_charges
patient = PatientAccount("John Doe")
while True:
print("Hospital Bill Menu:")
print("1. Add surgery")
print("2. Add medication")
print("3. Add day charge")
print("4. Set patient name")
print("5. Check out and calculate total charges")
choice = input("Enter choice (1-5): ")
if choice == "1":
surgery_type = input("Enter type of surgery: ")
cost = float(input("Enter cost: "))
patient.surgery(surgery_type, cost)
elif choice == "2":
medication_type = input("Enter type of medication: ")
cost = float(input("Enter cost: "))
patient.pharmacy(medication_type, cost)
elif choice == "3":
patient.dayCharge()
elif choice == "4":
name = input("Enter patient name: ")
patient.setName(name)
elif choice == "5":
total_charges = patient.getTotalCharges()
break
else:
print("Invalid choice. Try again.")
print("Thank you for using the hospital bill program.")
Step-by-step explanation:
This program defines a PatientAccount class that keeps track of the patient's name, days spent in the hospital, and charges. It also includes methods to add surgery and medication charges, add day charges, and set the patient name. The getTotalCharges method calculates the total charges based on the number of days spent in the hospital and the accumulated charges.
The program uses a while loop to display a menu of options and accept user input. The user can add surgery or medication charges, add a day charge, set the patient name, or check out and calculate the total charges. The loop continues until the user chooses to check out.