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.
Company : Portion of bill paid by insurance (%)
Wrightstown Mutual 80
Red Umbrella 60
All other companies 25
How to get the Company percentage listed above?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace pit
{
class InsuredPatient : Patient
{
public string InsuranceCompany { get; set; }
public string InsurancePercentage { get; set; }
}
class Patient : IComparable
{
public int ID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public double AmountDue { get; set; }
public override string ToString()
{
return ("Patient ID Number " + ID + "'s Name Is " + Name
+ "\nTheir Age Is " + Age
+ "\nAmountDue: " + AmountDue.ToString("C") + "\n");
}
int IComparable.CompareTo(Object o)
{
int returnVal;
Patient temp = (Patient)o;
if (this.ID > temp.ID)
returnVal = 1;
else
if (this.ID < temp.ID)
returnVal = -1;
else
returnVal = 0;
return returnVal;
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Wrightstown Hospital Billing Department\n\n");
InsuredPatient[] insuredPatient = new InsuredPatient[5];
int x;
int idNum;
int pAge;
double aDue;
for (x = 0; x < insuredPatient.Length; x++)
{
insuredPatient[x] = new InsuredPatient();
Console.WriteLine("Patient ID Number: ");
Int32.TryParse(Console.ReadLine(), out idNum);
insuredPatient[x].ID = idNum;
Console.WriteLine("Patient Name: ");
insuredPatient[x].Name = (Console.ReadLine());
Console.WriteLine("Patient Age: ");
Int32.TryParse(Console.ReadLine(), out pAge);
insuredPatient[x].Age = pAge;
Console.WriteLine("Amount Due: ");
double.TryParse(Console.ReadLine(), out aDue);
insuredPatient[x].AmountDue = aDue;
Console.WriteLine("Name of Insurance Company: ");
insuredPatient[x].InsuranceCompany = (Console.ReadLine());
}
Array.Sort(insuredPatient);
Console.WriteLine("\nPatient Summary Sorted: \n");
Console.WriteLine("-------------------------------\n");
for (x = 0; x < insuredPatient.Length; ++x)
Console.WriteLine(insuredPatient[x].ToString());
Console.ReadLine();
}
}
}