تم الحل ✓
categoryبرمجة وتطوير البرمجيات
schoolبكالوريوس
event_available2026-07-15
السؤال
Transcribed Image Text:
c) Write a base class Worker and derived classes HourlyWorker and
ContractWorker. Every worker has a name and a salary rate. Write functions
compute_pay(int hours) in the base class and derived classes that computes the
monthly pay for every worker. For base class, the worker gets paid the hourly
wage for 40 hours, no matter what the actual number of hours is. For derived
classes, an hourly worker gets paid the hourly wage for the actual number of hours
worked. If the hourly worker worked more than 40 hours, the excess is paid at time
and a half. The contract worker gets paid by number of project, no matter what the
actual number of hours is. Each project completed will get RM500.
Write a program using Polymorphism to test the Worker, HourlyWorker and
ContractWorker classes by creating instances of them asking the user to fill in
data with get_data() and then displaying it using display_salary().
check_circle الجواب — حل مفصل خطوة بخطوة
hourglass_top
🔒
الحل الكامل متاح للمشتركين
اشترك في أرشيف الأسئلة لعرض هذا الحل وآلاف الحلول المفصلة خطوة بخطوة من معلمين معتمدين.