1 / 1100%
//Steps to complete the class WeeklyEmployee (all that is required for the
quiz)
//Step 1: Make the WeeklyEmployee class
public class WeeklyEmployee{
//Step 2: Declare 3 instance variables for name, rate of pay, and hours worked
private String name;
private int hoursWorked;
private double rateOfPay;
//Step 3: Declare the constructor with 3 parameters to initialize the instance
variables
public WeeklyEmployee (String name, int hoursWorked, double rateOfPay ) {
name = WeeklyEmployee;
hoursWorked = hoursWorked;
rateOfPay = rateOfPay;
}
//Step 4: Declare the method toString that returns a String with WeeklyEmployee
name, and hourly rate of pay
public String tostring ()
{
return name = " " + rate + " " + hours;
}
//Step 5: Write the accessor method: getName() that returns the name
public String getName(){
return WeeklyEmployee;
}
//Step 6: Write the getGrossPay that computes and returns the pay for each
Weekly Employee by multiplying the rate times hours worked
public String getGrossPay(rateOfPay * hoursWorked){
return grossPay;
}
//Step 7: Write the mutator method setHours that takes the number of hours
worked as a double
public void setHours(double hoursWorked){
hoursWorked = newhoursWorked;
}
}
Powered by TCPDF (www.tcpdf.org)
Students also viewed