Question
I need help coding this please with the same output below. Posted it earlier but output was not the same. (Programming language is Java) public
I need help coding this please with the same output below. Posted it earlier but output was not the same. (Programming language is Java)
public abstract class Employee { private final String firstName; private final String lastName; private final Srring socialSecurityNumber;
//constructor public Employee(String firstName, String lastName, String socialSecurityNumber) { this.firstName = firstName; this.lastName = lastName; this.socialSecurityNumber = socialSecurityNumber; }
//return first name public String getFirstName() { return firstName; }
//return last name public String getLastName() { return lastName; }
//return social security number public String getSocialSecurityNumber() { return socialSecurityNumber; }
//return String representation of Employee object @Override public String toString() { return String.format("%s %s%nsocial security number: %s", getFirstName(), getLastName(), getSocialSecurityNumber)); } //abstract method must be overriden by concrete subclasses public abstract double earnings(); /o implementation here }//end abstract class Employee
//SalariedEmployee concrete class extends abstract class Employee
public class SalariedEmployee extends Employee { private double weeklySalary;
//constructor public SalariedEmployee(String firstName, String lastName, String socialSecurityNumber, double weeklySalary) { super(firstName, lastName, socialSecurityNumber);
if (weeklySalary = 0.0");
this.weeklySalary = weeklySalary; }
//set salary public void setWeekleySalary(double weeklySalary) { if (weeklySalary = 0.0");
this.weeklySalary = weeklySalary; }
//return salary public double getWeekly Salary() { return weeklySalary; }
//calculate earnings; override abstract method earnings in Employee @Override public double earnings() { return getweeklySalary(); }
//return String representation of SalariedEmployee object @Override public String toString() { return String.format("salaried employee: %s%n%s: $%,.2f"); super.toString(), "weekly salary", getWeeklySalary()); } }// end class SalariedEmployee
//HourlyEmployee class extends Employee
public class HourlyEmployee extends Employee { private double wage; //wage per hour private double hours; // hours worked for week
//constructor public HourlyEmployee(String firstName, String lastName, String socialSecurityNumber, double wage, double hours) { super(firstName, lastName, socialSecurityNumber);
if (wage = 0.0");
if (hours 168.0)) //validate hours throw new IllegalArgumentException("Hours worked must be >= 0.0 and
this.wage = wage; this.hours = hours; }
//set wage public void setWage(double wage) { if (wage = 0.0");
this.wage = wage; }
//return wage public double getWage() { return wage; }
//set hours worked public void setHours(double hours) { if ((hours 168.0)) // validate houurs throw new IllegalArgumentException("Hours worked must be >= 0.0 and
this.hours = hours; }
//return hours worked public double getHours() { return hours; }
//calculate earning; override abstract method earnings in Employee @Override public double earnings() { if (getHours()
//return String representation of HourlyEmployee object @Override public String toString() { return String.format("hourly employee: %s%n%s: $%,.2f; %s: %,.2f", super.toString(), "hourly wage", getWage(), "hours worked", getHours()); } } //end class HourlyEmployee
The Employee Classes Overview In this challenge, you will modify the code of the payroll system presented in Figures 10.4 through 10.6. The updated version will still implement a loop to calculate the monthly payroll for each Employee. It will now include birthdate information for each employee, and each employee will receive a $100.00 bonus if the current payroll month is the employee's birthdate month. Specifications Enter the original code shown in Figures 10.4 through 10.6 in your eBook text. Compile and run the code to ensure your entries are correct. Enter the Date class in Figure 8.7 and compile and run the code. Date Modify the Date class adding these methods: o getDay o getMonth o getYear o tostring (to return a String of the form month/daylyear)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started