Question
With the class Person, you are to extend a subclass named, PaidAdvisor whose variables, regularPayRate, specialPayRate, overtimePayRate, and hoursWorked should be defined before their being
With the class Person, you are to extend a subclass named, PaidAdvisor whose variables, regularPayRate, specialPayRate, overtimePayRate, and hoursWorked should be defined before their being used in the methods.
(a) Build a subclass, PaidAdvisor besides Person.
(b) regularPayRate is 25 dollars per an hour.
(c) specialPayRate is 50 dollars per an hour and is calculated separately.
(d) overtimePayRate is one and half time of the regular pay rate.
(e) Whenever the worker works more than 30 hours, the overtime pay rate kicks in and the pay is calculated accordingly. However, special work hours are separately calculated. Say, you have worked 40 hours. Your system must be able to ask a separate question like, Have you worked for a special session? If so (say your special session hours are 5), you need to subtract the special hours from the total hours (35 total hours and 5 special session hours). Calculate the pay accordingly (maybe you can add a variable like hoursSpecial?).
(f) Define the constructors that sets regularPayRate/specialPayRate/ overtimePayRate and hoursRegular/hoursSpecial and 0 or the set values (e.g., rate or hours).
(g) Define the method, toString(), that returns the wages based on the method, calculatePay().
(h) Define the method, calculatePay(), that calculates the multiplication of the pay rate (the regular pay rate and the overtime pay rate) and the hours worked.
(i) Define the method, getPayRate(), that returns either of the pay rates (regular or overtime).
(j) Define the method, getHoursWorked(), that returns the hours worked.
(k) Define the method, setNameRateHours(), that sets the name, rate and hours for the research consultant.
(l) After building all the parts as above, then build a program that asks the user to enter the hours and calculates the pay as the test program. **Use the class Person below.
public class Person {
private String firstName; private String lastName; public Person() { firstName = ""; lastName = ""; } public Person(String first, String last) { setName(first, last); } public String toString() { return (firstName + " " + lastName); } public void setName(String first, String last) { firstName = first; lastName = last; } public String getFirstName() { return firstName; } public String getLasttName() { return lastName; } }
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