Create a class named employee


1. Create a class named Employee as follows.
a. The instance (or member) private variables - name (String) and wageRate (integer). The wageRate denotes the weekly wages (@40 hours/week) for this employee.
b. A single constructor with two arguments, the name and the wage rate. Set the instance variables with the specified argument values.
c. The public set and get methods for the two instance variables.
d. A public computePayStub method which takes a double argument, named hours, and returns a double showing the weekly wages for this employee. The employee is only paid for a maximum of 40 hours for the week based on the weekly wageRate. If this employee worked less than 40 hours, the wages are prorated accordingly.
e. Override the toString method to return the string representation of this object in the format "Employee:@mce_markerlt;wageRate>/week".
2. Create a derived class from the Employee class named Consultant. 
a. No instance variables are allowed in the Consultant class.
b. A single constructor with two arguments, the name and the wage rate. The wage rate represents the hourly rate of this consultant.
c. Override the computePayStub method which takes a double argument, named hours, and returns a double showing the weekly wages for this consultant. The consultant is paid for the week based on the hourly wageRate for the first 40 hours. If this consultant worked more than 40 hours, the excess hours are paid at 1.5 times the hourly rate. However, a maximum of 10 overtime hours is allowed for the pay period.
d. Override the toString method to return the string representation of this object in the format "Consultant:@mce_markerlt;wageRate>/hour".

3. Create a Test class to test the following functionality in its main method.
a. Declare a variable named currentEmployee of type Employee.
b. Create an Employee object with name Alice and the weekly wage rate 1000 and assign it to the above variable.
c. Print to the console the string representation of this object.
d. Using any of the loop constructs, iterate over the computePayStub of this object with the hours 10, 20, 30, 40, 50, and 60. Display the wages as shown in the sample below.
e. Create a Consultant object with name Bob and the hourly wage rate 100. Reassign the currentEmployee to this object.
f. Repeat the steps shown in c) and d) for this object.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Create a class named employee
Reference No:- TGS0103831

Expected delivery within 24 Hours