Lab Assignment 5 - Inheritance
Lab Assignment 5 - Inheritance
1.1 Given the following superclass named Food and subclass named WesternFood.
v. Write the processor methods named Payment() which calculates and returns the
amount to be paid by the customer based on the following table:
(MNOS2024) 1|Page
The customers need to pay extra RM 10.90 if they want the set that comes with dessert.
Besides, 10% discount will be given to the members.
i. Store data into an array of objects. The number of data to be stored and information
on each of the customers is given by the user.
iii. Count and display the number of customers who make a desert order.
iv. Calculate and display the total amount from the member's customers.
v. Calculate and display the total amount of charges for all customers.
vi. Display the details of customer’s information who make an order the Lamb Chop set.
Employee
-name:String
-id: int
-Position:String
+Employee()
+Employee(String,int,String)
+setName(String):void
+setId(int):void
+setPosition(String):void
+getName():String
+getId():int
+getPosition():String
+toString():String
Permanent PartTime
-basicSalary:double -ratePerHour:double
-houseAllowance:double -totWorkingHour:double
+PartTime()
+Permanent() +PartTime(String,int,String,double, double)
+Permanent(String,int,String,double, double) +setRatePerHour(double):void
+setBasicAllowance(double):void +setTotWorkingHour(double):void
+setHouseAllowance(double):void +getRatePerHour():double
+getBasicAllowance():double +getTotWorkingHour():double
+getHouseAllowance():double +calcSalary():double
+calcSalary():double +toString():String
+toString():String
(MNOS2024) 2|Page
• Input the appropriate data for each employee. Use array of objects to store the details of
the employees.
• Print a slip for each employee that shows the details of the employee including the payment.
• For processor (method calcSalary()):
• At the end of the process, print a report that shows the following information:
1.3 By referring to the Final Examination Paper (December 2019), PART B, QUESTION 3. Write a
complete Java program.
1.4 By referring to the Final Examination Paper (February 2023), PART B, QUESTION 3. Write a
complete Java program.
1.5 By referring to the Final Examination Paper (July 2023), PART B, QUESTION 3. Write a complete
Java program.
1.6 By referring to the Final Examination Paper (January 2024), PART B, QUESTION 3. Write a
complete Java program.
(MNOS2024) 3|Page