This is done in C# Create a Patient class for the Wrightstown Hospital Billing D
ID: 3534067 • Letter: T
Question
This is done in C# Create a Patient class for the Wrightstown Hospital Billing Department. Include a patient ID number, name, age, and amount due to the hospital. Include properties and any other methods you need. Override the ToString() method to return all the details for a patient. Write an application that prompts the user for data for five Patients. Sort them in patient ID number order and display them all, including a total amount owed. Save the program as PatientDemo.es. Using the Patient class as a base, derive an InsuredPatient class. An InsuredPatient contains all the data of a Patient, plus fields to hold an insurance company name, and the percentage of the hospital bill the insurance company will pay. Insurance payments are based on the following table: Insurance Company Portion of bill paid by insurance (%) Wrightstown Mutual 80 Red Umbrella 60 All other companies 25 Create an array of five InsuredPatient objects. Create a program that justifies the following:Explanation / Answer
Hi, I have combined the code here. The method takeFiveNameOfPatients() and class Patient performs task for PatientDemo.cs. The method takeFiveNameOfInsuredPatients() and class InsuredPatient performs task for PatientDemo2.cs . Rest all the required functions are defined underneath. Hope it is helpful :)
public class Patient
{
public int patientID;
public string name;
public int number;
public int age;
public int dueamount;
public string toString()
{
return "Patient Name"+name+" Patient Id"+patientID+" Patient Number"+number+"Patient Age"+age+"DueAmount"+dueamount;
}
}
public class InsuredPatient : Patient
{
public string companyName;
public int percent;
public int getInsurePercent(string name)
{
if(name.Equals("Wrightstown Mutual"))
percent=80;
else if(name.Equals("Red Umbrella"))
percent=60;
else percent=25;
return percent;
}
public string toString()
{
percent=percent/100;
int amountleft=dueamount*percent;
dueamount=dueamount-amountleft;
return "Patient Name"+name+" Patient Id"+patientID+" Patient Number"+number+"Patient Age"+age+"DueAmount"+dueamount+"Insurance Company"+companyName+" Percent"+percent;
}
}
public class Test
{
public void sortAndPrint(Patient[] patient)
{
Array.Sort(patient,delegate(Patient x, Patient y) { return x.patientID.CompareTo(y.patientID); });
for(int i=0;i<patient.Length;i++)
patient[i].toString();
}
public void takeFiveNameOfInsuredPatients()
{
InsuredPatient[] insuredPatient=new InsuredPatient[5];
for(int i=0;i<5;i++)
{
Console.WriteLine("Enter Name:");
insuredPatient[i].name=Console.ReadLine();
Console.WriteLine("Enter Number:");
insuredPatient[i].number=Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter Age:");
insuredPatient[i].age=Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter ID:");
insuredPatient[i].patientID=Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter dueAmount:");
insuredPatient[i].dueamount=Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter Insurance Company Name");
insuredPatient[i].companyName=Console.ReadLine();
insuredPatient[i].percent=insuredPatient[i].getInsurePercent(insuredPatient[i].companyName);
}
}
public void takeFiveNameOfPatients()
{
Patient[] patient=new Patient[5];
int total=0;
for(int i=0;i<5;i++)
{
Console.WriteLine("Enter Name:");
patient[i].name=Console.ReadLine();
Console.WriteLine("Enter Number:");
patient[i].number=Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter Age:");
patient[i].age=Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter ID:");
patient[i].patientID=Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter dueAmount:");
patient[i].dueamount=Int32.Parse(Console.ReadLine());
total=total+patient[i].dueamount;
}
sortAndPrint(patient);
Console.WriteLine("Total Amount Due is:"+total);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.