Create three files: Payroll class.java -Base class definition PayrollOvertime.jave - Derived class definition PayrollOvertimeClient.java - contains main() method Implement the two user define classes with the following specifications: Payroll class (the base class)  5 data fields(protected) String name - Initialized in default constructor to "John Doe" int ID - Initialized in default constructor to 9999 doulbe payRate - Initialized in default constructor to 15.0 doulbe hrWorked - Initialized in default constructor to 40 static int data field named nOfObjs for tracking the number of employees, (initialized to 0 and updated nOfObjs++ in the constructors) 2 constructors (public) Default constructor (make sure to update the nOfObjs member) A constructor that accepts the employee’s name, ID, and pay rate as arguments. These values should be assigned to the object’s name, ID, and payRate fields, also update the nOfObjs member 8 public member methods (mutators, accessors, and other) getNOfObjts() getName() getID() setPayRate() & getPayRate() setHrWorked() & getHrWorked() A method named grossPay that returns employee’s gross pay (=hrWorked * payRate) PayrollOvertime class (the derived class) 2 private fields double overtimePayRate- Initialized in default constructor to 22.5 double overtimeHrWorked - Initialized in default constructor to 0 2 constructors (public)  Default constructor (use super() to invoke the Payroll constructor ) A constructor that accepts the employee’s name, ID, and pay rate, over time pay rate as arguments. These values should be assigned to the object’s name, ID, payRate, and overtimePayRate fields. (use super() to invoke the Payroll constructor ) 5 public member methods (mutators, accessors, and other) getOvertimePayRate() & setOvertimeHrWorked (double) getOvertimeHrWorked() & setOvertimePayRate(double) Override the grossPay method of Payroll class, that returns employee’s gross pay (hrWorked * payRate+ overtimePayRate *overtimeHrWorked) ClientClass In main() method, create two PayrollOvertime objects (one use the info inputted by the user and the other use the default constructor); and print the info for each employee Ex: Enter the name, ID, pay rate, overtime pay rate, regular hours and overtime worked of an employee: Linda Smith 1234 20.5 30.25 35 10 Record 1 Name: Linda Smith ID: 1234 Regular pay rate: $ 20.5 Overtime pay rate: $ 30.25 Regular hours worked: 35.0 Overtime hours worked: 10.0 Gross pay: $1020.00 Record 2 Name: John Doe ID: 9999 Regular pay rate: $ 15.0 Overtime pay rate: $ 22.5 Regular hours worked: 40.0 Overtime hours worked: 0.0 Gross pay: $600.00

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 7E
icon
Related questions
Question

Create three files:

  • Payroll class.java -Base class definition
  • PayrollOvertime.jave - Derived class definition
  • PayrollOvertimeClient.java - contains main() method

Implement the two user define classes with the following specifications:

Payroll class (the base class) 

  • 5 data fields(protected)

    • String name - Initialized in default constructor to "John Doe"
    • int ID - Initialized in default constructor to 9999
    • doulbe payRate - Initialized in default constructor to 15.0
    • doulbe hrWorked - Initialized in default constructor to 40
      • static int data field named nOfObjs for tracking the number of employees, (initialized to 0 and updated nOfObjs++ in the constructors)
  • 2 constructors (public)

    • Default constructor (make sure to update the nOfObjs member)
    • A constructor that accepts the employee’s name, ID, and pay rate as arguments. These values should be assigned to the object’s name, ID, and payRate fields, also update the nOfObjs member
  • 8 public member methods (mutators, accessors, and other)

    • getNOfObjts()
      • getName()
      • getID()
      • setPayRate() & getPayRate()
      • setHrWorked() & getHrWorked()
      • A method named grossPay that returns employee’s gross pay (=hrWorked * payRate)

PayrollOvertime class (the derived class)

  • 2 private fields

    • double overtimePayRate- Initialized in default constructor to 22.5
    • double overtimeHrWorked - Initialized in default constructor to 0
  • 2 constructors (public) 

    • Default constructor (use super() to invoke the Payroll constructor )
    • A constructor that accepts the employee’s name, ID, and pay rate, over time pay rate as arguments.
      These values should be assigned to the object’s name, ID, payRate, and overtimePayRate fields. (use super() to invoke the Payroll constructor )
  • 5 public member methods (mutators, accessors, and other)

    • getOvertimePayRate() & setOvertimeHrWorked (double)
    • getOvertimeHrWorked() & setOvertimePayRate(double)
    • Override the grossPay method of Payroll class, that returns employee’s gross pay (hrWorked * payRate+ overtimePayRate *overtimeHrWorked)

ClientClass In main() method, create two PayrollOvertime objects (one use the info inputted by the user and the other use the default constructor); and print the info for each employee

Ex:

Enter the name, ID, pay rate, overtime pay rate, regular hours and overtime worked of an employee:

Linda Smith

1234

20.5

30.25

35

10

Record 1

Name: Linda Smith

ID: 1234

Regular pay rate: $ 20.5

Overtime pay rate: $ 30.25

Regular hours worked: 35.0

Overtime hours worked: 10.0

Gross pay: $1020.00

Record 2

Name: John Doe

ID: 9999

Regular pay rate: $ 15.0

Overtime pay rate: $ 22.5

Regular hours worked: 40.0

Overtime hours worked: 0.0

Gross pay: $600.00

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Properties of CSS
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,