Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given the following superclass named Hospital and subclasses named Inpatient and Outpatient. Abstract Superclass: Hospital Attributes: Methods: String name String gender int age //
Given the following superclass named Hospital and subclasses named Inpatient and Outpatient. Abstract Superclass: Hospital Attributes: Methods: String name String gender int age // patient's name patient's gender (male or female) // patient's age in year constructor, mutator, accessor, printer, abstract method abstract double caleCharges () // calculate the charges Subclass: Attributes: Methods: Inpatient int wardType; int day; double treatment Fee; // ward type // number of days stay // treatment charges constructor, mutator, accessor, printer Subclass: Outpatient Attributes: double Methods: consultationFee double medicineFee String consultationDate // consultation fee // medicine fee // (dd/mm/yyyy) // e.g 15/10/2018 constructor, mutator, accessor, printer a) Write the normal constructor for Inpatient and Outpatient classes. b) Write a method calcCharge () for both subclasses to calculate the charge to be paid by the patients of the hospital. For senior citizens, they are entitle to get 50% discount for the charges. The patients are considered as senior citizens when their ages are greater than 60 years old. The daily ward charges for inpatients are shown in the following table: Ward Type 1 (1-bed) Charges (RM) /day 350 2 (2-bed) 250 4 (4-bed) 100 The charge for inpatients is calculated based on the given formula: Charges ward charges + treatment fee For outpatients, they only have to pay for consultation and medicine fees. c) Write program fragments that use the concept of polymorphism to perform the following: i) Declare an array of objects to store 100 patients. ii) Display the detail of female inpatients that have been admitted to the hospital. iii) Count and display the inpatient's details who have been admitted in the hospital for more than 10 days. iv) Calculate and display the total charges of all outpatients in the month of October 2018
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started