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

Hello. I need some help troubleshooting my program. I am having trouble combinin

ID: 3591101 • Letter: H

Question

Hello. I need some help troubleshooting my program. I am having trouble combining my classes: address, employee name and date. I need to connect them, so that I will be able to attach my subclasses to this program. With just the name class, I was able to effectively run my program, but I was unable to run my program with the addition of the address and date classes. Thank you.

class EmployeeClassName {

  

//get and return firstName, lastName, and employeeNumber

  

   private String firstName;

   private String lastName;

   private int employeeNumber;

  

   public String getFirstName()

   {

       return firstName;

   }

   public String getLastName()

   {

       return lastName;

   }

  

   public int getEmployeeNumber()

   {

       return employeeNumber;

   }

  

  

   public EmployeeClassName (String fn, String ln, int en)

   {

       firstName = fn;

       lastName = ln;

       employeeNumber = en;              

   }

}

//address class

   class address{

   String street;

   String city;

   String state;

   String zipcode;

   // constructor of class

   public address(String street, String city, String state, String zipcode) {

   super();

   this.street = street;

   this.city = city;

   this.state = state;

   this.zipcode = zipcode;

   }

   // get and return street

   public String getStreet() {

   return street;

   }

   public String getCity() {

   return city;

   }

   public String getState() {

   return state;

   }

   public String getZipcode() {

   return zipcode;

   }

   }

  

   // date class

class date{

       int month;

       int day;

       int year;

       // get and return month

       public int getMonth() {

       return month;

       }

       public int getDay() {

       return day;

       }

       public int getYear() {

       return year;

       }

      

       class Employee {

           public void main (String args []) {  

           Employee( String fn, String ln, String en, String street, String city, String state, String zipcode, int month, int day, int year )

           {

          

  

       SalariedEmployee employee1 = new SalariedEmployee("Suzie", "Palmer", 135 Pheasant Run, Argyle, TX, 76226, 12005, 126000);

      

       System.out.println(employee1.getFirstName() + " " + employee1.getLastName() + " " + employee1.address.getStreet() + " " + employee1.address.getCity() + " " + employee1.address.getState() + " " + employee1.address.getZipcode() + " " + employee1.date.getMonth() + "/" + employee1.date.getDay() + "/" + employee1.date.getYear() + employee1.getEmployeeNumber() + " " +employee1.annualSalary);

      

      

  

      

           }

  

   }}

class SalariedEmployee extends Employee {

  

   double annualSalary;

  

   SalariedEmployee(String fn, String ln, String street, String city, String state, String zipcode, int month, int day, int year, int en, double as);

   {

       super(fn, ln, street, city, state, zipcode, month, day, year, en);

       annualSalary = as;

      

      

   }

}

//these are my two classes

class HourlyEmployee extends Employee {

  

   double hourlyPayRate;

   double hoursWorked;

   double earnings;

  

   HourlyEmployee(String fn, String ln, int en,String street, String city, String state, String zipcode, int month, int day, int year, double hpr, double hw, double e)

   {

       super(fn, ln, street, city, state, zipcode, month, day, year, en);

       hourlyPayRate = hpr;

       hoursWorked = hw;

       earnings = e;  

   }

       double getEarnings ()

       {

           if (hoursWorked >40 )

           {

               earnings = hourlyPayRate * 1.5 * hoursWorked;

           }

           else

           {

               earnings = hourlyPayRate * hoursWorked;

           }

           return earnings;

          

       }

}}

Explanation / Answer

class EmployeeClassName {
  
//get and return firstName, lastName, and employeeNumber
  
private String firstName;
private String lastName;
private int employeeNumber;
  


public String getFirstName()
{
return firstName;
}

public String getLastName()
{
return lastName;
}
  
public int getEmployeeNumber()
{
return employeeNumber;
}
  
  
public EmployeeClassName (String fn, String ln, int en)
{
firstName = fn;
lastName = ln;
employeeNumber = en;   
}
}


//address class

class Address{ // better to use Class names starting with Capital letter

String street;
String city;
String state;
String zipcode;

// constructor of class

public address(String street, String city, String state, String zipcode) {

super();

this.street = street;

this.city = city;

this.state = state;

this.zipcode = zipcode;

}

// get and return street

public String getStreet() {

return street;

}


public String getCity() {

return city;

}


public String getState() {

return state;

}


public String getZipcode() {

return zipcode;

}
}  

// date class

class Date{ // better to use Class names starting with Capital letter

int month;

int day;

int year;

// get and return month

public int getMonth() {

return month;

}


public int getDay() {

return day;

}


public int getYear() {

return year;

}
}

// if you want to use the classes(EmployeeClassName, Address, Date) you have to extend those classes
class Employee extends EmployeeClassName, Address, Date{   

public void main (String args []) {   

Employee( String fn, String ln, String en, String street, String city, String state, String zipcode, int month, int day, int year )
{
SalariedEmployee employee1 = new SalariedEmployee("Suzie", "Palmer", 135 Pheasant Run, Argyle, TX, 76226, 12005, 126000);
  
System.out.println(employee1.getFirstName() + " " + employee1.getLastName() + " " + employee1.address.getStreet() + " " + employee1.address.getCity() + " " + employee1.address.getState() + " " + employee1.address.getZipcode() + " " + employee1.date.getMonth() + "/" + employee1.date.getDay() + "/" + employee1.date.getYear() + employee1.getEmployeeNumber() + " " +employee1.annualSalary);
}
  
}
}
class SalariedEmployee extends Employee {
  
double annualSalary;
  
SalariedEmployee(String fn, String ln, String street, String city, String state, String zipcode, int month, int day, int year, int en, double as);
{
super(fn, ln, street, city, state, zipcode, month, day, year, en);
annualSalary = as;
}
}


//these are my two classes
class HourlyEmployee extends Employee {
  
double hourlyPayRate;
double hoursWorked;
double earnings;
  
HourlyEmployee(String fn, String ln, int en,String street, String city, String state, String zipcode, int month, int day, int year, double hpr, double hw, double e)
{
super(fn, ln, street, city, state, zipcode, month, day, year, en);
hourlyPayRate = hpr;
hoursWorked = hw;
earnings = e;   
}

double getEarnings (){
if (hoursWorked >40 ){
earnings = hourlyPayRate * 1.5 * hoursWorked;
}
else{
earnings = hourlyPayRate * hoursWorked;
}
return earnings;
}
}

Note: use starrting and closing braces( '{ }' ) appropriately