Question: [ Assignment5_yourlastname.cs ] Implement the following requirements: Create a class named Patient that has the following data members: patient number (int), use a full accessor
[Assignment5_yourlastname.cs] Implement the following requirements:
Create a class named Patient that has the following data members:
patient number (int), use a full accessor implementation, not automatic accessors.
patient name (string), use a full accessor implementation, not automatic accessors.
patient age (int), use a full accessor implementation, not automatic accessors.
amount due (double) from patient, use a full accessor implementation, not automatic accessors.
A class constructor that assigns default values of patient number = 9, name = "ZZZ", patient age = 0, patient amount due = 0.
A class constructor that takes four parameters to assign input values by way of the accessors for patient number, name, age, amount due.
The default values will be implemented through the default constructor by referencing the this pointer when the no argument constructor is implemented when assigning a patient object to the object array in Main.
The patient class should be set up so that its objects are comparable to each other based on object patient numbers (implement IComparable) and can be sorted by patient id number. This means you will also have to override the object GetHashCode method and override the Equals(Object e) class method to compare two patient objects by patient number.
You will override the patient object ToString method. The overridden ToString method will return a string output as shown in the output example. You will return a string to the Console.Writeline in Main that will use the object GetType() method to display "Patient" followed by the patient number, name, age, and amount due formatted as currency as shown in the output example.
In Main:
instantiate an array of five (5) Patient objects.
Implement a for-loop that will instantiate each Patient object in turn and assign it to an array element.
prompt the user to enter a patient number.
Implement a for-loop that will use the Patient object Equals method to compare the Patient objects in the array and determine if the patient number entered is a duplicate.
If it is a duplicate then implement a while loop that will prompt the user that the id entered is a duplicate and to reenter a valid patient id; then check again using Equals to compare the number entered to the other patient object id numbers entered in the array.
once a valid id number is entered then request entries for the name, age and amount due for the current Patient object.
Once all five Patient array objects have been entered you will sort the array of objects by patient id number.
Write an output line that will give the header "Payment Information" (see output example).
Implement a public static GetPaymentAmount method that will be called from Main.
The GetPaymentAmount method will be passed the this pointer for the current Patient object from the object array.
set a constant for the number of quarters in a year equal to 4.
return to the method call (assign to payment variable in Main) the Patient object amount due divided by the constant number of quarters.
Implement a for-loop that will call the static GetPaymentAmount method passing the each (this pointer) object in the Patient object array.
assign the current payment value returned from the GetPaymentAmount static method to an output variable declared in Main.
use a console write to implement the overridden Patient object ToString method (see output example).
use a write line to display "Quarterly payment is " followed by the payment extracted from the current object payment due.
Internal documentation.
Possible output for the program would look like this:
Enter patient number 5 Enter name dick Enter age 55 Enter amount due 5555.55 Enter patient number 2 Enter name jack Enter age 22 Enter amount due 2222.22 Enter patient number 4 Enter name joe Enter age 44 Enter amount due 4444.44 Enter patient number 1 Enter name tom Enter age 11 Enter amount due 1111 Enter patient number 4 Sorry, the patient number 4 is a duplicate. Please reenter 1 Sorry, the patient number 1 is a duplicate. Please reenter 3 Enter name jane Enter age 33 Enter amount due 3333.33 Payment Information: Patient 1 tom 11 AmountDue is $1,111.00 Quarterly payment is 277.75 Patient 2 jack 22 AmountDue is $2,222.22 Quarterly payment is 555.555 Patient 3 jane 33 AmountDue is $3,333.33 Quarterly payment is 833.3325 Patient 4 joe 44 AmountDue is $4,444.44 Quarterly payment is 1111.11 Patient 5 dick 55 AmountDue is $5,555.55 Quarterly payment is 1388.8875 Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
