Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient, the following data should be entered:
• The number of days spent in the hospital
• The daily rate
• Hospital medication charges
• Charges for hospital services (lab tests, etc.)
The program should ask for the following data if the patient was an out-patient:
• Charges for hospital services (lab tests, etc.)
• Hospital medication charges
The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the in-patient data, while the other function accepts arguments for out-patient information. Both functions should return the total charges.
Input Validation: Do not accept negative numbers for any data.
Solved 1 Answer
See More Answers for FREE
Enhance your learning with StudyX
Receive support from our dedicated community users and experts
See up to 20 answers per week for free
Experience reliable customer service
Step 1using System;class Patient{private string patient;private string guardian;//get and set methodspublic string GetPatient(){return patient;}public void SetPatient(string patient){this.patient = patient;}public string GetGuardian(){return guardian;}public void SetGuardian(string guardian){this.guardian = guardian;}// constructorspublic Patient(){patient = "";guardian = "";}public Patient(string patient, string guardian){this.patient = patient;this.guardian = guardian;}public Patient(string patient){this.patient = patient;}// overloaded functionspublic double GetCharges(int days, double dailyRate, double medCharges){return (days*dailyRate + medCharges);}public double GetCharges(double labCharges, double medCharges){return (labCharges + medCharges);}}public class Test{public static void Main(){  Patient patient = new Patient();Console.WriteLine("Is the patient was admittedin this hospital? Enter y for yes: ");string minor = Console.ReadLine();if(minor == "y"){Console.WriteLine("Please enter the patient's full name: ");string name = Console.ReadLine();Console.WriteLine("Please enter the guardian's full name: ");string guardian = Console.ReadLine();patient.SetPatient(name);patient.SetGuardian(guardian);}else{Console.WriteLine("Please enter the patient's full name: ");string name = Console.ReadLine();patient.SetPatient(name);}Console.WriteLine("Was the patient an in-patient or out-patient? (i) for in-patient (o) for out-patient: ");string inOutPatient = Console.ReadLine();if(inOutPatient == "i"){Console.WriteLine("Please enter the number of days spent in the hospital: ");int days = Convert.ToInt32(Console.ReadLine());Console.WriteLine("Please enter the daily rate: ");double dailyRate = Convert.ToDouble(Console.ReadLine());Console.WriteLine("Please enter the amount of medication charges: ");double medCharges = Convert.ToDouble(Console.ReadLine());Console.WriteLine("The total charge for {0} is ${1:0.00}", patient.GetPatient(), patient.GetCharges(days,dailyRate,medCharges));}else if(inOutPatient == "o"){Console.WriteLine("Please enter the total charges for hospital lab tests: ");double labCharges = Convert.ToDouble(Console.ReadLine());Console.WriteLine("Please enter the amount of medication charges: ");double medCharges = Convert.ToDouble(Console.ReadLine());Console.WriteLine("The total charge for {0} is ${1:0.00}", patient.GetPatient(), patient.GetCharges(labCharges,medCharges));}elseConsole.WriteLine("Invalid option");}}Step 2Step 3RunDebugStop E ShareH Save{} Beautifymain.cs1 using System;23 class Patient4 \div\{private string patient;private string guardian;8 \mathrm{llget} and set methods9 public string GetPatient()10-\{11 return patient;12\}13 public void SetPatient(string patient)Is the patient was admittedin this hospital? Enter y for yes:inputIs the patient was admittedin this hospital? Enter y for yes:yPlease enter the patient's full name:Boby BartelPlease enter the guardian's full name:Bartel BobyWas the patient an in-patient or out-patient? (i) for in-patient (o) for out-patient:0Please enter the total charges for hospital lab tests:425Please enter the amount of medication charges:326The total charge for Boby Bartel is \$ 751.00...Program finished with exit code 0Press ENTER to exit console. ...