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

Hello! I have almost completed my program. I have bolded the area that I am stuc

ID: 3591768 • Letter: H

Question

Hello! I have almost completed my program. I have bolded the area that I am stuck on. As you can see, employee2 and employee3 rely on a return value, "earnings" that is calculated from hourlyPayRate and hoursWorked. How would I incorporate this in my string? Please help me get my program running. I have spent a lot of hours on it. :)

class EmployeeClassName {

  

      

      

      

       private String firstName;

       private String lastName;

      

      

       //get and return firstName, lastName, and employeeNumber

       public String getFirstName()

       {

       return firstName;

       }

       public String getLastName()

       {

       return lastName;

       }

      

      

      

       //refer to object EmployeeClassName

       public EmployeeClassName (String firstName, String lastName)

       {

       this.firstName = firstName;

       this.lastName = lastName;

      

      

       }

       }

      

class Address{

       private String street;

       private String city;

       private String state;

       private String zipcode;

       // get and return street, city, state, zipcode

       public String getStreet()

       {

       return street;

       }

       public String getCity()

       {

       return city;

       }

       public String getState()

       {

       return state;

       }

       public String getZipcode()

       {

       return zipcode;

       }

      

      

       // refer to Address object

       public Address(String street, String city, String state, String zipcode)

       {

           this.street = street;

           this.city = city;

           this.state = state;

           this.zipcode = zipcode;  

      

       }

       }

      

       class Date{

       private int month;

       private int day;

       private int year;

       public Date(int month2, int day2, int year2) {

           // TODO Auto-generated constructor stub

       }

       // get and return month

       public int getMonth()

       {

           return month;

       }

       public int getDay()

       {

           return day;

       }

       public int getYear()

       {

       return year;

       }

       }

      

          

class EmployeeClass

{

   EmployeeClassName employeeClassName;

  

   Address address;

  

   Date date;

  

   int employeeID;

EmployeeClass(String firstName, String lastName, String street, String city, String state, String zipcode, int month, int day, int year, int employeeID) {

  

   this.employeeClassName = new EmployeeClassName( firstName, lastName);

  

   this.address = new Address(street, city, state, zipcode);

  

   this.date = new Date(month, day, year);

  

   this.employeeID = employeeID;

  

}

public String getFirstName ()

{

   return employeeClassName.getFirstName();

}

public String getLastName ()

{

   return employeeClassName.getLastName();

}

public String getStreet ()

{

   return address.getStreet();

}

public String getCity ()

{

   return address.getStreet();

}

public String getState()

{

   return address.getState();

}

public String getZipcode()

{

   return address.getZipcode();

}

public int getMonth()

{

   return date.getMonth();

}

public int getDay()

{

   return date.getDay();

}

public int getYear()

{

   return date.getYear();

}

public int getEmployeeID()

{

   return employeeID;

}

}      

      

      

      

      

      

      

      

//these are okay I think. I am just having trouble connecting all 3 of the classes above.

      

      

  

class SalariedEmployee extends EmployeeClass

{

          

          

       double annualSalary;

      

       SalariedEmployee(String firstName, String lastName, String street, String city, String state, String zipcode,

           int month, int day, int year, int employeeID, double annualSalary)

      

{

      

       super(firstName, lastName, street, city, state, zipcode, month, day, year, employeeID);

       // TODO Auto-generated constructor stub

}

       public double getAnnualSalary()

           {

               return annualSalary;

           }

          

public void main (String args [])

{

      

      SalariedEmployee employee1 = new SalariedEmployee("Suzie", "Palmer","135 Pheasant", "Argyle", "TX", 76226, 01, 17, 2010, 126000.0);

       System.out.println(employee1.getFirstName() + " " + employee1.getLastName() + " " + employee1.getStreet() + " " + employee1.getCity() + " " + employee1.getState() + " " + employee1.getZipcode() + " " + employee1.getMonth() + "/" + employee1.getDay() + "/" + employee1.getYear() + employee1.getEmployeeID() + " " + employee1.getAnnualSalary());

      

       HourlyEmployee employee2 = new HourlyEmployee("Suzie", "Palmer","135 Pheasant", "Argyle", "TX", 76226, 01, 17, 2010, 41 );

       System.out.println(employee2.getFirstName() + " " + employee2.getLastName() + " " + employee2.getStreet() + " " + employee2.getCity() + " " + employee2.getState() + " " + employee2.getZipcode() + " " + employee2.getMonth() + "/" + employee2.getDay() + "/" + employee2.getYear() + employee2.getEmployeeID() + " " + employee2.getHoursWorked() + "/t" + employee2.getHourlyPayRate() + " " + employee2.getEarnings());

      

       HourlyEmployee employee3 = new HourlyEmployee(("Suzie", "Palmer","135 Pheasant", "Argyle", "TX", 76226, 01, 17, 2010, 41,);

       System.out.println(employee3.getFirstName() + " " + employee3.getLastName() + " " + employee3.getStreet() + " " + employee3.getCity() + " " + employee3.getState() + " " + employee3.getZipcode() + " " + employee3.getMonth() + "/" + employee3.getDay() + "/" + employee3.getYear() + employee3.getEmployeeID() + " " + employee3.getHoursWorked() + "/t" + employee3.getHourlyPayRate() + " " + employee3.getEarnings());

}

}

      

      

       //these are my two classes

       class HourlyEmployee extends EmployeeClass {

      

       double hourlyPayRate;

       double hoursWorked;

       double earnings;

      

       HourlyEmployee(String firstName, String lastName, String employeeNumber, String street, String city, String state, String zipcode, int month, int day, int year, int employeeID, double hourlyPayRate, double hoursWorked, double earnings) {

      

       super(firstName, lastName, street, city, state, zipcode, month, day, year, employeeID);

      

  

       }

      

       public double getHourlyPayRate()

       {

           return hourlyPayRate;

       }

      

       public double getHoursWorked()

       {

           return hoursWorked;

       }

       double getEarnings (){

       if (hoursWorked >40 ){

       earnings = hourlyPayRate * 1.5 * hoursWorked;

       }

       else{

       earnings = hourlyPayRate * hoursWorked;

       }

       return earnings;

       }

       }

Explanation / Answer

i have a code so far

public class Employee {

private String name;

private int id;

private double salary;

private int age;

private String position;

public double getFedTax() {

return (salary - 800) * 0.17;

}

public int getSsTax(int rate) {

return (int) (rate * salary / 100.00);

}

public int getHealthFee(int rate) {

return (int) (rate * salary / 100.00);

}

public int getInsurance() {

int rate = 0;

if (age < 40) {

rate = 3;

} else if (age > 40 && age <= 50) {

rate = 4;

} else if (age > 50 && age <= 60) {

rate = 5;

} else {

rate = 6;

}

return (int) (rate * salary / 100.00);

}

public double getNetPay() {

return salary - getSsTax(1) - getHealthFee(3) - getFedTax()

- getInsurance();

}

public String getName() {

return name;

}

public int getId() {

return id;

}

public double getSalary() {

return salary;

}

public int getAge() {

return age;

}

public String getPosition() {

return position;

}

public void setName(String name) {

this.name = name;

}

public void setId(int id) {

this.id = id;

}

public void setSalary(double salary) {

this.salary = salary;

}

public void setAge(int age) {

this.age = age;

}

public void setPosition(String position) {

this.position = position;

}

@Override

public String toString() {

String s = "";

s += " Name: " + getName();

s += " Id: " + getId();

s += " Salary: $" + getSalary();

s += " Age: " + getAge();

s += " Position: " + getPosition();

s += " Fed Tax: $" + getFedTax();

s += " SS Tax: $" + getSsTax(1);

s += " Health Fee: $" + getHealthFee(3);

s += " Insurance: $" + getInsurance();

s += " Net Pay: $" + getNetPay();

return s;

}

public static void main(String[] args) {

Employee john = new Employee();

john.setAge(45);

john.setId(101);

john.setName("John Q. Public");

john.setPosition("Network Engineer");

john.setSalary(75200.00);

System.out.println(john);

Employee jane = new Employee();

jane.setAge(29);

jane.setId(202);

jane.setName("Jane Doe");

jane.setPosition("Security Assistant");

jane.setSalary(45000.00);

System.out.println(jane);

}

}

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