Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design an interface called payable in Java with the following methods: double calculatepay ( ) - This method should calculate and return the amount of
Design an interface called payable in Java with the following methods:
double calculatepay This method should calculate and return the amount of pay for an employee.
Now, create two classes HourlyEmployee and salariedemployee that implement the Payable interface.
Implement the calculatepay method in each class to represent the pay calculation for an hourly employee
and a salaried employee respectively.
For the HourlyEmployee class:
It should have instance variables for hourly wage and hours worked.
Implement the calculatepay method to calculate the pay as the product of hourly wage and hours
worked.
For the
class:
It should have an instance variable for the annual salary.
Implement the calculatepay method to calculate the pay as the annual salary divided by the number of
pay periods in a year eg for monthly pay
In main. Instantiate objects of
and salariedEmployee classes, set their attributes, and print the
amount of pay for each employee using the calculatepay method.
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