Question

In: Computer Science

Fill in the classes to represent salaried and hourly employees. Salaried employees are paid for forty...

Fill in the classes to represent salaried and hourly employees. Salaried employees are paid for forty hours no matter how much they actually work. Hourly employees are paid their hourly rate up to forty hours of work, and 1.5 times their normal rate for overtime.

Employee.java

public abstract class Employee {
protected double payRate;
  
public Employee(double payRate) {
this.payRate = payRate;
}
  
   abstract public double computePay(double hours);
}

HourlyEmployee.java

public class HourlyEmployee extends Employee {
   public HourlyEmployee(double payRate) {
   }
  
   public double computePay(double hours) {
       return 0;
   }
}

SalariedEmployee.java

public class SalariedEmployee extends Employee {
   public SalariedEmployee(double payRate) {
   }
  
   public double computePay(double hours) {
       return 0;
   }
}

Solutions

Expert Solution

Employee

//Abstract class Employee
public abstract class Employee 
{
        //Instance variable
        protected double payRate;

        //Constructor
        public Employee(double payRate)
        {
                //Initializing instance variable from value received as argument
                this.payRate = payRate;
        }
        
        //Abstract method to compute pay of Employee
        abstract public double computePay(double hours);
}

SalariedEmployee

//Class SalariedEmployee derived from base class Employee
public class SalariedEmployee extends Employee 
{       
        //Constructor
        public SalariedEmployee(double payRate) 
        {
                //Calling base class constructor
                super(payRate);
        }

        //Overridden method to compute pay
        @Override
        public double computePay(double hours) 
        {
                //Returning pay for default 40 hours
                return 40 * this.payRate;
        }
}

HourlyEmployee

//Class HourlyEmployee derived from base class Employee
public class HourlyEmployee extends Employee 
{
        //Constructor
         public HourlyEmployee(double payRate) 
         {
                 //Calling base class constructor
                 super(payRate);
         }

        //Overridden method to compute pay       
        @Override
        public double computePay(double hours)
        {
                //Checking whether hours is greater than 40 or not
                if(hours <= 40)
                        //Returning pay when hours less than or equal to 40
                        return hours * this.payRate;
                else
                        //Returning pay when hours greater than 40
                        return (40*this.payRate) + ((hours-40)*this.payRate*1.5);
        }
}

Since, only these three classes are asked to fill, there won't be any output for this


Related Solutions

Write a program that calculates pay for either hourly paid workers or salaried workers. Hourly paid...
Write a program that calculates pay for either hourly paid workers or salaried workers. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are payed their regular salary plus any bonus they may have earned. The program should declare two structures for the following data: • Hourly Paid ◦HoursWorked ◦ HourlyRate • Salaried ◦ Salary ◦ Bonus The program should also declare a structure with two members. Each member should be a...
Write a C++ program that calculates pay for either hourly paid workers or salaried workers.
Write a C++ program that calculates pay for either hourly paid workers or salaried workers. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are payed their regular salary plus any bonus they may have earned. The program should declare two structures for the following data:• Hourly Paid◦ HoursWorked◦ HourlyRate• Salaried◦ Salary◦ BonusThe program should also declare a structure with two members. Each member should be a structure variable: one for the...
The average hourly paid for employees in food-service industries is currently $16.49. Suppose we take a...
The average hourly paid for employees in food-service industries is currently $16.49. Suppose we take a sample of 45 employees to see if the average hourly paid differs from the claimed average of $16.49. The sample mean obtained is $17.91. Assume that the population standard deviation is $2.1 per hour. Conduct the hypothesis test at α=0.01 . State the hypotheses, test statistics, critical value, decision and conclusion. Round your numbers to 3 decimal places.
Bonita Hardware has four employees who are paid on an hourly basis plus time-and-a-half for all...
Bonita Hardware has four employees who are paid on an hourly basis plus time-and-a-half for all hours worked in excess of 40 a week. Payroll data for the week ended March 15, 2020, are presented below. Employee Hours Worked Hourly Rate Federal Income Tax Withholdings United Fund Ben Abel 40 $15 $? $5 Rita Hager 42 16 ? 5 Jack Never 44 13 60 8 Sue Perez 46 13 61 5 Abel and Hager are married. They claim 0 and...
Forty five percent of employees in a firm are female. A sample of 49 employees is...
Forty five percent of employees in a firm are female. A sample of 49 employees is selected randomly. What is the probability that the sample proportion of females is at least 0.45?
The file Assign1_Data contains data on the hourly wages (Hourly Wage) of all employees of a...
The file Assign1_Data contains data on the hourly wages (Hourly Wage) of all employees of a grocery chain in the Ottawa region. (a) Treating this set of data as the population, use Minitab to calculate the population mean and the population standard deviation for the Hourly Wage variable. (b) Examine a boxplot and histogram of the population data. Explain if the means of all possible random samples of size 40 from this population would form a normal distribution. (c) Using...
Forty percent of a firm’s employees are men. Suppose Four of the firm’s employees are randomly...
Forty percent of a firm’s employees are men. Suppose Four of the firm’s employees are randomly selected. a. What is more likely, finding three men and one woman or two men and two women? _The probabilities of finding three men and one woman and two men and two women are the same. _Finding two men and two women are more likely. _Finding three men and one woman is more likely. b. Do you obtain the same answer as in part...
Vargas Company has 35 employees who work 8-hour days and are paid hourly. On January 1,...
Vargas Company has 35 employees who work 8-hour days and are paid hourly. On January 1, 2019, the company began a program of granting its employees 10 days of paid vacation each   year. Vacation days earned in 2019 may first be taken on January 1, 2020. Any days not taken in one year can be carried forward for up to two years. Information relative to these employees is as follows: (5 points)                    Hourly              Vacation Days Earned    Vacation Days Used Year            Wages               by Each...
The monthly and hourly wage schedule for the employees of Quirk, Inc., follows. No employees are...
The monthly and hourly wage schedule for the employees of Quirk, Inc., follows. No employees are due overtime pay. Round your answer to nearest cent. Compute the following for the last monthly pay of the year: a. The total wages of each part-time employee for December 2018. b. The OASDI and HI taxable wages for each employee. c. The FICA taxes withheld from each employee's wages for December. d. Totals of columns. (Totals should include both full-time and part-time employees.)...
The XYZ Corporation is interested in possible differences in days worked by salaried employees in three...
The XYZ Corporation is interested in possible differences in days worked by salaried employees in three departments in the financial area. An analysis of 27 randomly chosen employees reveals the number of days worked data . a) Use JMP to fit a one-way ANOVA to the data. Using alpha= 0.05 draw a conclusion for the ANOVA. Make sure you state your conclusion in the context of the problem. b) Use tukey’s test with alpha= 0.05 to determine which departments’ workers...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT