Program Description:
This project will have you create a simple class hierarchy building upon the Employee example discussed in class.
A total of five classes are required.
Employee – A class which the other employee types inherit from
HourlyEmployee – An employee whose pay is based upon an hourly wage and hours worked
SalaryEmployee – An employee whose pay is based upon a yearly salary
CommissionEmployee – An employee whose pay is based upon a commission rate and sales amount
EmployeeTest – Contains main method. Creates one of each sub type of Employee and performs actions upon them.

Content of

public class EmployeeTest
   public static void main(String args[])
      //Create references for our objects
      HourlyEmployee hourly;
      SalaryEmployee salary;
      CommissionEmployee commission;

      //The sum of all bonuses will be placed here
      double bonusPayout = 0;

      //Create and print a new HourlyEmployee
      hourly = HourlyFactory();
      System.out.printf("\n%s\n", hourly);
      //Create and print a new SalaryEmployee
      salary = SalaryFactory();      
      System.out.printf("\n%s\n", salary);
      //Create and print a new CommissionEmployee
      commission = CommissionFactory();
      System.out.printf("\n%s\n", commission);

      //Alter some values of Hourly and Commission
      System.out.println("Increasing Hourly's hours worked by 50.");

      System.out.println("Increasing Commissions's sales by 150,000.\n");

      //Output weekly pay for each Employee
      System.out.printf("Hourly Payout: %.2f\n", hourly.calculateWeeklyPay());
      System.out.printf("Salary Payout: %.2f\n", salary.calculateWeeklyPay());
      System.out.printf("Commission Payout: %.2f\n\n", commission.calculateWeeklyPay());

      //Find total bonus payout
      System.out.println("Finding total bonus payout...");
      bonusPayout += hourly.holidayBonus();
      bonusPayout += salary.holidayBonus();
      bonusPayout += commission.holidayBonus();

      System.out.printf("Bonus Payout is %.2f\n\n", bonusPayout);

      //Reset the week and apply raises to all Employees
      System.out.println("Applying annual raises and resetting week...");

      //Output Employees after changes
      System.out.printf("%s\n%s\n%s\n", hourly, salary, commission);

   //Retrieve input and create HourlyEmployee
   public static HourlyEmployee HourlyFactory()
      System.out.println("Creating HourlyEmployee...");
      return new HourlyEmployee("Steve", "Rogers", 'A', 'M', 12345, true, 15.34);
   //Retrieve input and create SalaryEmployee
   public static SalaryEmployee SalaryFactory()
      System.out.println("Creating SalaryEmployee...");
      return new SalaryEmployee("Kitty", "Pryde", 'X', 'F', 54321, true, 75000);
   //Retrieve input and create CommissionEmployee
   public static CommissionEmployee CommissionFactory()
      System.out.println("Creating CommissionEmployee...");
      return new CommissionEmployee("Johnny", "Storm", 'F', 'L', 976499, false, 2.5);

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.text.DecimalFormat;

* @author
public class HourlyEmployee extends Employee{
    /// atrributes
    private double wage;
    private double hoursWorked;

    * constructor
    * @param firstName
    * @param lastName
    * @param middleInitial
    * @param gender
    * @param employeeNum
    * @param fulltime
    * @param wage
    public HourlyEmployee(String firstName, String lastName, char middleInitial, char gender, int employeeNum, boolean fulltime, double wage) {
       super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
       this.wage = wage;
       this.hoursWorked = 0.0;
    * Requesting to increase by a negative value should give no change, and report an error to the user.
    * @param hours
    public void increaseHours(double hours){
       if (hours < 0.0) {
            System.out.println("It's unable to increase by a negative value");
       } else {
            hoursWorked += hours;

By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats