Question: public class Employee { private double[] hours=new double[7]; private String name; public Employee(double[] hours, String name) { super(); this.hours = hours; this.name = name; }
![public class Employee { private double[] hours=new double[7]; private String name;](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f501bedd094_79866f501be58023.jpg)
![public Employee(double[] hours, String name) { super(); this.hours = hours; this.name =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f501bf8d585_79966f501bf26697.jpg)
public class Employee { private double[] hours=new double[7]; private String name; public Employee(double[] hours, String name) { super(); this.hours = hours; this.name = name; } public double[] getHours() { return hours; } public void setHours(double[] hours) { this.hours = hours; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int numDaysWorked(){ int total_D=0; for(int i=0;i
return total_H; } public double hoursWorkedOnday(int day){ return hours[day]; } public String toString(){ return name+" Worked for" +numDaysWorked() + " day(s) for a total of "+totalHours() + "hours ."; } }
import java.util.Scanner;
public class EmployeeTester { private static Scanner employee; public static void main(String[] args) { String name; int week_day=0; employee = new Scanner(System.in); System.out.print("Enter a name : "); name=employee.next(); System.out.print("Enter hours worked (7 values separated by spaces):"); double hours[]=new double[7]; for(int i=0;i The class diagram for HW 1, Problem 2 is shown below. Employee Tester Employee -hours:double[7] main(argsO:string) -name:string +Employee (name: string) +getHours(day:int):double +setHours (day:int, hrs: double) +numaDaysWorked0:int +totalHours0: double +toString0:string 1. Copy the Employee and Employee Tester classes from HW 1, Problem 2 into your project in the Prob2 folder/package 2. Add a wages method to the Employee class. This method accepts a pay rate ($/hr) that the employee earns. The method computes the pay by multiplying the total hours by the pay rate (e.g. no overtime). Hint: all you have to do is multiply the result of totalHours0 by the pay rate. Example (assume pay rate of $10/hr) 3. Add a subclass, HourlyEmployee. Override the wages method so that it computes and returns the pay using the pay rate for the first 40 hours and time-and-a-half for any hours over 40.0. Four examples (assume pay rate of $10/hr): hours M Tu W ITh F Sa Su Reg Wages ICOT Wages Total Wages 10 10 10 10 10 6 0 $400.00 $240.00 S640.00 hours IM Tu TW Th F Sa Su Reg Wages OT Wages Total Wages 10 0 10 10 0 4 0 $340.00 $0.00 $340.00 hours M Tu W ITh IF Sa Su Reg Wages TOT Wages Total Wages 10 10 10 10 100 0 0 $400.00 $150.00 $550.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
