Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA programming Language: Write a class Employee that represents a single hourly employee and a class PayCheckthat calculates employee pay for the week. Employees know

JAVA programming Language:

Write a class Employee that represents a single hourly employee and a class PayCheckthat calculates employee pay for the week. Employees know their names (String) the number of hours they worked in a given week, and their pay rate. PayChecks know an employee name, a rate, and the hours worked. PayChecks calculate the weekly pay based on rate * hours if the hours are 40 or less. If the hours worked exceeds 40, the PayCheck applies an overtime rate of 1.5x for all of the hours in excess of 40. Create:

  • An Employee constructor that takes a name and pay rate as parameters and sets the instance values appropriately. This constructor should also initialize the hours worked to zero (0) upon instantiation.

  • An Employee method addHoursWorked() which takes a parameter (double) and adds the value of that parameter to the current number of hours the Employee has worked this week.

  • An Employee method resetHoursWorked() that resets the employees hours worked for the week to zero.

  • An Employee method getWeeklyCheck() which, when called, returns a new PayCheck object that is initialized to the current Employee name, rate and hours worked.

  • A PayCheck constructor that takes the employee name, rate, and hours worked as parameters and calculates (and stores) the total pay for the week.

  • A PayCheck method getTotalPay() that returns the total pay for the week.

  • A toString method for BOTH classes, allowing Employee objects to be represented by the employee name, and PayCheck objects by the totalPay (in proper dollars/cents $xxx.yy format).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions