Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is a java program for employees. I keep getting errors (11 to be exact) lik

ID: 3795597 • Letter: H

Question

Here is a java program for employees. I keep getting errors (11 to be exact) like this one below:

/Employees.java:11: cannot find symbol
symbol : constructor Salary(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,double)
location: class Salary

I was wondering if anyone can help me fix my errors and if it were possible, to combine some of the classes together. THank you!

*******************************************************************************************************************

import java.util.*;

public class CoffeeShop
{
public static void main(String[] args)
{
Employees personnel = new Employees();
  
personnel.payday();
}

}

*******************************************************************************************************************

class Employees
{
private StaffMember[] employee;

// Constructor: Sets up the list of staff members with personal information
public Employees()

{
employee = new StaffMember[8];
  
employee[0] = new Salary("Christian Hayes", "001", "329 Broadway", "Manhatten", "(631) 293-7483", "General Manager", "Salary", "628-26-1102", 1824.10);
  
employee[1] = new Salary("Taylor James", "002","17 32nd Street", "Brooklyn", "(631) 210-4837", "Assistant Manager", "Salary", "428-43-6632", 1335.36);
  
employee[2] = new Salary("Alexa Connors","003", "195 First Avenue", "Manhatten", "(718) 581-3820", "Accountant", "Salary", "948-77-2391", 1199.75);
  
employee[3] = new Hourly("Brady Berger", "004","678 Fifth Avenue.", " Tribeca", "(917) 429-1829", "Barista", "Hourly", "817-95-6632", 12.25);
  
employee[4] = new Hourly("Henry Ronalado", "005","987 Houston Street", "SoHo", "(212) 358-0090", "Barista", "Hourly", "128-73-8192", 13.00);
  
employee[5] = new Hourly("Lila Underwood", "006","892 Eastham Boulevard", "Queens", "(631) 818-9048", "Baker", "Hourly", "514-29-1820", 12.75);
  
employee[6] = new Hourly("Bella Forbes", "007","11 Second Avenue", "(347) 736-3029", "Brooklyn", "Baker", "Hourly", "234-52-4038", 12.25);
  
employee[7] = new Hourly("Harry Clifford", "008","88 Washington Street","(929) 714-2133", "Manhatten", "Counter Attendant", "Hourly", "838-24-7732", 13.50);
  
((Salary)employee[0]).salesBonus(500.00);
  
((Hourly)employee[3]).addHours(40);
((Hourly)employee[4]).addHours(23);
((Hourly)employee[5]).addHours(17);
((Hourly)employee[6]).addHours(35);   
((Hourly)employee[7]).addHours(47);
}
  
// Pays all staff members
public void payday()
{
double amount;
  
// polymorphic
for (int count = 0; count < employee.length; count++)
{
System.out.println(employee[count]);
  
amount = employee[count].pay(); //polymorphic
  
if (amount == 0.0)
System.out.println("No paycheck this week");
else
System.out.println("Expected paycheck amount: " + amount);
  
System.out.println("-----------------------------------");
}
}
}

*******************************************************************************************************************

public class Hourly extends Payroll
{
protected int hoursWorked;
  
public Hourly(String empName, String empId, String empAddress, String empCity, String empPhoneNo, String empPosition, String sSN, double rate)
{
super(empName, empId, empAddress, empCity, empPhoneNo, empPosition, sSN, rate);
  
hoursWorked = 0;
}
  
public void addHours(int overTime)
{
hoursWorked += overTime;
}
  
public double pay()
{
double paycheck = wage * hoursWorked;
  
hoursWorked = 0;
  
return paycheck;
}
  
public String toString()
{
String result = super.toString();
  
result += " Current hours worked this week: " + hoursWorked;
  
return result;
}
}

*******************************************************************************************************************

// Payroll Class represents specified information of a typical employee

public class Payroll extends StaffMember
{
protected String name;
protected String idNumber;
protected String address;
protected String city;
protected String phoneNo;
protected String position;
protected String payroll;
protected String socialSecNo;
protected double wage;
  
// Constructor sets up employee Payroll with the specified infomation
// @Param empName - Employee Name

public Payroll (String empName, String empId, String empAddress, String empCity, String empPhoneNo, String empPosition, String empPayroll, String sSN, double rate)
{
// Call the superclass instructor
// The first line in the constructor of the derived class must be a call to the superclass
super (empName, empId, empAddress, empCity, empPhoneNo, empPosition, empPayroll);

socialSecNo = sSN;
wage = rate;
}
  
// Returns the pay rate for this employee
public double getWage()
{
return wage;
}
  
// Returns information about an employee as a string   
public String toString()
{
String result = super.toString();
  
result += " SSN: " + socialSecNo;
  
return result;
}
// Returns the amount this employee should be paid
public double pay()
{
return wage;
}
}

*******************************************************************************************************************

public class Salary extends Payroll
{
private double bonus;
  
public Salary(String empName, String empId, String empAddress, String empCity, String empPhoneNo, String empPosition, String sSN, double rate)
{
super(empName, empId, empAddress, empCity, empPhoneNo, empPosition, sSN, rate);
  
bonus = 0;
}
  
public void salesBonus(double salaryBonus)
{
bonus = salaryBonus;
}
  
public double pay()
{
double paycheck = super.pay() + bonus;
  
bonus = 0;
  
return paycheck;
}
}

*******************************************************************************************************************

// The pay method will differ for each subclass of StaffMember and is therefore
// made to be abstract, forcing it to be defined by the subclasses

abstract public class StaffMember
{
protected String name;
protected String idNumber;
protected String address;
protected String city;
protected String phoneNo;
protected String position;
  
// Constructor sets up this staff member using the specified information
public StaffMember (String empName, String empId, String empAddress, String empCity, String empPhoneNo, String empPosition)
{
name = empName;
idNumber = empId;
address = empAddress;
city = empCity;
phoneNo = empPhoneNo;
position = empPosition;
}
  
// Returns a string including the basic employee information
public String toString()
{
String result = "Name: " + name + " ";
result += "Employee ID: " + idNumber + " ";
result += "Address: " + address + " ";
result += "City: " + city + " ";
result += "Phone Number: " + phoneNo + " ";
result += "Job Title: " + position;
  
return result;
}
  
// Derived classes must define the pay method for each type of employee
public abstract double pay();
}

Explanation / Answer


I have done changes in constructors of 3 classes- Hourly, Payroll, and Salary.
You were calling the constructor which wasn't even defined. (The number of parameters in the defined constructor of superclass was different than the number of parameters in the call to superclass constructor inside subclass constructor.

Hourly.java:

public class Hourly extends Payroll
{
protected int hoursWorked;
  
public Hourly(String empName, String empId, String empAddress, String empCity, String empPhoneNo, String empPosition, String empPayroll, String sSN, double rate)
{
super(empName, empId, empAddress, empCity, empPhoneNo, empPosition, empPayroll, sSN, rate);
  
hoursWorked = 0;
}
  
public void addHours(int overTime)
{
hoursWorked += overTime;
}
  
public double pay()
{
double paycheck = wage * hoursWorked;
  
hoursWorked = 0;
  
return paycheck;
}
  
public String toString()
{
String result = super.toString();
  
result += " Current hours worked this week: " + hoursWorked;
  
return result;
}
}

Payroll.java:

public class Payroll extends StaffMember
{
protected String name;
protected String idNumber;
protected String address;
protected String city;
protected String phoneNo;
protected String position;
protected String payroll;
protected String socialSecNo;
protected double wage;
  
// Constructor sets up employee Payroll with the specified infomation
// @Param empName - Employee Name
public Payroll (String empName, String empId, String empAddress, String empCity, String empPhoneNo, String empPosition, String empPayroll, String sSN, double rate)
{
// Call the superclass instructor
// The first line in the constructor of the derived class must be a call to the superclass
super(empName, empId, empAddress, empCity, empPhoneNo, empPosition);
payroll=empPayroll;
socialSecNo = sSN;
wage = rate;
}
  
// Returns the pay rate for this employee
public double getWage()
{
return wage;
}
  
// Returns information about an employee as a string   
public String toString()
{
String result = super.toString();
  
result += " SSN: " + socialSecNo;
  
return result;
}
// Returns the amount this employee should be paid
public double pay()
{
return wage;
}
}

Salary.java:

public class Salary extends Payroll
{
private double bonus;
  
public Salary(String empName, String empId, String empAddress, String empCity, String empPhoneNo, String empPosition, String empPayroll, String sSN, double rate)
{
super(empName, empId, empAddress, empCity, empPhoneNo, empPosition,empPayroll, sSN, rate);
  
bonus = 0;
}
  
public void salesBonus(double salaryBonus)
{
bonus = salaryBonus;
}
  
public double pay()
{
double paycheck = super.pay() + bonus;
  
bonus = 0;
  
return paycheck;
}
}


Output I am getting:

Name: Christian Hayes
Employee ID: 001
Address: 329 Broadway
City: Manhatten
Phone Number: (631) 293-7483
Job Title: General Manager
SSN: 628-26-1102
Expected paycheck amount: 2324.1
-----------------------------------
Name: Taylor James
Employee ID: 002
Address: 17 32nd Street
City: Brooklyn
Phone Number: (631) 210-4837
Job Title: Assistant Manager
SSN: 428-43-6632
Expected paycheck amount: 1335.36
-----------------------------------
Name: Alexa Connors
Employee ID: 003
Address: 195 First Avenue
City: Manhatten
Phone Number: (718) 581-3820
Job Title: Accountant
SSN: 948-77-2391
Expected paycheck amount: 1199.75
-----------------------------------
Name: Brady Berger
Employee ID: 004
Address: 678 Fifth Avenue.
City: Tribeca
Phone Number: (917) 429-1829
Job Title: Barista
SSN: 817-95-6632
Current hours worked this week: 40
Expected paycheck amount: 490.0
-----------------------------------
Name: Henry Ronalado
Employee ID: 005
Address: 987 Houston Street
City: SoHo
Phone Number: (212) 358-0090
Job Title: Barista
SSN: 128-73-8192
Current hours worked this week: 23
Expected paycheck amount: 299.0
-----------------------------------
Name: Lila Underwood
Employee ID: 006
Address: 892 Eastham Boulevard
City: Queens
Phone Number: (631) 818-9048
Job Title: Baker
SSN: 514-29-1820
Current hours worked this week: 17
Expected paycheck amount: 216.75
-----------------------------------
Name: Bella Forbes
Employee ID: 007
Address: 11 Second Avenue
City: (347) 736-3029
Phone Number: Brooklyn
Job Title: Baker
SSN: 234-52-4038
Current hours worked this week: 35
Expected paycheck amount: 428.75
-----------------------------------
Name: Harry Clifford
Employee ID: 008
Address: 88 Washington Street
City: (929) 714-2133
Phone Number: Manhatten
Job Title: Counter Attendant
SSN: 838-24-7732
Current hours worked this week: 47
Expected paycheck amount: 634.5
-----------------------------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote