Question

5. a. Create a Patient class for the Wrightstown Hospital Billing Department. Include auto-implemented prop- erties for a pat

PLEASE ANSWER IN C#

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have answered a) as per HomeworkLib rules so please upload b and c separately in 2 different posts.

using System;
using System.Collections.Generic;

namespace WrightstownHospitalBillingDepartment
{
    //Personal record model 
    public class Patient
    {
        /// <summary>
        /// Contains Patient id number
        /// </summary>
        public int PatientIdNumber { get; set; }

        /// <summary>
        /// Contains Patient name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Contains age of patient
        /// </summary>
        public int Age { get; set; }

        /// <summary>
        /// Contains amount due to the hospital
        /// </summary>
        public int AmountDueToTheHospital { get; set; }
    }

    public class Comparer : IComparer<Patient>
    {
        //Comparer function in order to sort list by comparing two patient number
        public int Compare(Patient x, Patient y)
        {
            //Compare the patient id number 
            return x.PatientIdNumber.CompareTo(y.PatientIdNumber);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            //Adding the records in the list of personal record
            List<Patient> patientRecords = new List<Patient>();

            Console.WriteLine("Enter Five Patient Details");

            //Read the data from console and adding into the list
            for (int i = 0; i < 5; i++)
            {
                //Creating patient object
                Patient patient = new Patient();

                Console.Write("Enter Patient Id Number: ");

                //Reading patient id number
                string value = Console.ReadLine();
                patient.PatientIdNumber = Convert.ToInt32(value);

                Console.Write("Enter Patient Name: ");

                //Reading patient name
                value = Console.ReadLine();
                patient.Name = value;

                Console.Write("Enter Patient Age: ");

                //Reading patient age
                value = Console.ReadLine();
                patient.Age = Convert.ToInt32(value);

                Console.Write("Enter amount due to the hospital: ");

                //Reading Amount Due To The Hospital
                value = Console.ReadLine();
                patient.AmountDueToTheHospital = Convert.ToInt32(value);

                //Add recond into the list
                patientRecords.Add(patient);
            }

            //Created a object of comparer
            Comparer comparer = new Comparer();

            //Sort list using comparer object
            patientRecords.Sort(comparer);

            //Print recond in the console after sorting
            Console.WriteLine("\nPatient Records ->");

            //Contains total ammount owed
            int totalAmountOwed = 0;

            Console.WriteLine($"Patient Id number\tPatient Name\tPatient Age\tAmount Due To The Hospital");

            //Iterating each patient
            foreach (var personalRecord in patientRecords)
            {
                //Conculating total ammount owed
                totalAmountOwed += personalRecord.AmountDueToTheHospital;

                //Print all patient details
                Console.WriteLine($"{personalRecord.PatientIdNumber}\t{personalRecord.Name}\t{personalRecord.Age}\t{personalRecord.AmountDueToTheHospital}");
            }

            //Print total amount owed to the hospital
            Console.WriteLine("Total amount owed to hospital: {0}", totalAmountOwed);
        }
    }
}

Code Images:-1 using System; using System.Collections.Generic; 2 3 4 5 6 7 references 7 8 namespace WrightstownHospitalBillingDepartment {23 24 25 26 /// <summary> /// Contains amount due to the hospital /// </summary> 3 references public int AmountDueToTheHospit40 41 42 class Program { O references static void Main(string[] args) { //Adding the records in the list of personal record L67 Console.Write(Enter Patient Age: ); 68 69 //Reading patient age value = Console.ReadLine(); patient. Age = Convert.ToIntConsole.WriteLine($Patient Id number\tPatient Name\tPatient Age\tAmount Due To The Hospital); //Iterating each patient fore

Input And Output:-

Enter Five Patient Details
Enter Patient Id Number: 10
Enter Patient Name: Ramesh
Enter Patient Age: 15
Enter amount due to the hospital: 30000
Enter Patient Id Number: 9
Enter Patient Name: Suresh
Enter Patient Age: 20
Enter amount due to the hospital: 40000
Enter Patient Id Number: 7
Enter Patient Name: Dinesh
Enter Patient Age: 25
Enter amount due to the hospital: 50000
Enter Patient Id Number: 1
Enter Patient Name: Lala
Enter Patient Age: 18
Enter amount due to the hospital: 25010
Enter Patient Id Number: 8
Enter Patient Name: ChaCha
Enter Patient Age: 20
Enter amount due to the hospital: 100000

Patient Records ->
Patient Id number       Patient Name    Patient Age     Amount Due To The Hospital
1                                       Lala                    18                      25010
7                                       Dinesh                  25                      50000
8                                       ChaCha                  20                      100000
9                                       Suresh                  20                      40000
10                                      Ramesh                  15                      30000
Total amount owed to hospital: 245010

Here i have added code and code images and also inout and output of the code. Explenation also provided in the code itself.

Thank You!

Add a comment
Know the answer?
Add Answer to:
PLEASE ANSWER IN C# 5. a. Create a Patient class for the Wrightstown Hospital Billing Department....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C#: Create an application class named BillDemo that instantiates objects of two classes named Bill...

    Using C#: Create an application class named BillDemo that instantiates objects of two classes named Bill and OverdueBill, and that demonstrates all their methods. The Bill class includes auto-implemented properties for the name of the company or person to whom the bill is owed and for the amount due. Also, include a ToString() method and returns a string that contains the name of the class (using GetType()) and the Bill’s data fields values. Create a child class named OverdueBill that...

  • This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description:...

    This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...

  • Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter...

    Using C# Create an application class named LetterDemo that instantiates objects of two classes named Letter and CertifiedLetter and that demonstrates all their methods. The classes are used by a company to keep track of letters they mail to clients. The Letter class includes auto-implemented properties for the Name of the recipient and the Date mailed (stored as strings). Next, include a ToString() method that overrides the Object class’s ToString() method and returns a string that contains the name of...

  • Create an Item class, which is the abstract super class of all Items.           Item class...

    Create an Item class, which is the abstract super class of all Items.           Item class includes an attribute, description of type String for every item. [for eg. Book]                                                             A constructor to initialize its data member of Item class.               Override toString() method to return details about the Item class. Create the ExtraCharge interface with the following details.                       Declare a constant RATE with value 0.25   Declare a method called calculateExtraCharge(), which returns a double value. Create the...

  • Create a java project and create Student class. This class should have the following attributes, name...

    Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...

  • Create a data class named Automobile that implements the Comparable interface. Give the class data fields...

    Create a data class named Automobile that implements the Comparable interface. Give the class data fields for make, model, year, and price. Then add a constructor, all getters, a toString method that shows all attribute values, and implement Comparable by using the year as the criterion for comparing instances. Write a program named TestAutos that creates an ArrayList of five or six Automobiles. Use a for loop to display the elements in the ArrayList. Sort the Arraylist of autos by...

  • (To be written in Java code) Create a class named CollegeCourse that includes the following data...

    (To be written in Java code) Create a class named CollegeCourse that includes the following data fields: dept (String) - holds the department (for example, ENG) id (int) - the course number (for example, 101) credits (double) - the credits (for example, 3) price (double) - the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display()...

  • Write a python program that computes a patients bill for a hospital stay. The different components of the program are The patientAccount class The Surgery class The Pharmacy class The main program -Th...

    Write a python program that computes a patients bill for a hospital stay. The different components of the program are The patientAccount class The Surgery class The Pharmacy class The main program -The PatientAccount class will keep a total of the patient's charges. It will also keep track of the number of days spent in the hospital. The group must decide on the hospital's daily rate. -The Surgery class will have stored within it the charges for at least five...

  • Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super...

    Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...

  • QUESTION 5 (15 Marks) Inheritance and Polymorphism Design a Ship class that has the following members:...

    QUESTION 5 (15 Marks) Inheritance and Polymorphism Design a Ship class that has the following members: • A private String data field named name for the name of the ship. • A private String data field named yearBuilt for the year that the ship was built. • A constructor that creates a ship with the specified name and the specified year that the ship was built. • Appropriate getter and setter methods. A toString method that overrides the toString method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT