Hi I need help with a java programming project specifically

Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an introduction to problem solving and programming. it tells me to define a class named employee whose objects are records for employees, it then tells me to derive the class from a class called person. it tells me that the employee record should contain an annual salary(represented as single value of type double), a hire date(that gives hired year as single type of int) and a social security number or ssn as a value of type string. My professor provided us a test program to test out both classes, but I am having a hard time figuring out how to get both classes to work within my test program.

Here is my person class

public class Person
{
public String name;


public Person()
{
name = \"No name yet.\";
}

public Person(String initialName)
{
name = initialName;
}

public void setName(String newName)
{
name = newName;
}

public String getName()
{
return name;
}

public void writeOutput()
{
System.out.println(\"Name: \" + name);
}

public boolean sameName(Person otherPerson)
{
return (this.name.equalsIgnoreCase(otherPerson.getName()));
}


}

Here is my Employee class

public class Employee extends Person
{

private double annualSalary;

private int hiredYear;


private String SSN;

//constructors which include parameters such as employee name, salary and hire date

public Employee (String initialName, double initialSalary, int joinedYear, String id)
{
super(initialName);

annualSalary = initialSalary;

hiredYear = joinedYear;


SSN = \"000-00-0000\";
}

//sets salary


public void setAnnualSalary( double newSalary)
{
annualSalary = newSalary;
}


//sets year hired


public void sethiredYear( int year)
{
hiredYear = year;
}



  


//set employee ssn

public void setSSN(String newSSN)
{
SSN = newSSN;   
}

// return annual salary

public double getAnnualSalary()
{
return annualSalary;
}
  
//return hired year
  
public int getHiredYear()
{
return hiredYear;
}
  
  
  
//return SSN
  
public String getSSN()
{
return SSN;
}
  
  
  
  
  
//return true if both employee objects are the same. Otherwise return false
  
public boolean equals(Employee otherEmployee)
{
if(name.equals(otherEmployee.name))
  
if(annualSalary == otherEmployee.annualSalary)
  
if(hiredYear == otherEmployee.hiredYear)
  

  
if(SSN == otherEmployee.SSN)
  
  
return true;

return false;

}


//prints employee name, annual salary, year hired and ID


public void display()
{
System.out.println(\"Employee name: \" + name);
System.out.println(\"Employee salary: \" + annualSalary);
System.out.println(\"Employee hired year: \" + hiredYear);

System.out.println(\"employee ssn: \" + SSN);
System.out.println();
}
}

  

and here is my Employeetest program my professor provided( the big thing he said is that I am not allowed to alter this test program in anyway.

import java.util.*;

public class EmployeeTest
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
char repeat;

do // repeat if user says \'yes\'
{
// Test the nine constructors (uses writeOutput method)

Employee e1 = new Employee(); // default constructor
System.out.println(\"Using default constructor:\");
e1.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

Employee e2 = new Employee(\"Mondo Kane\");
System.out.println(\"Using constructor with just name:\");
e2.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

Employee e3 = new Employee(\"Fleetis Pascal\", 111111.11);
System.out.println(\"Constructor with name & salary :\");
e3.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

          Employee e4 = new Employee(\"Carl Wolf\", 1968);
System.out.println(\"Constructor with name and hire date:\");
e4.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

Employee e5 = new Employee(\"Sharon Kelly\", \"123-45-6789\");
System.out.println(\"Constructor with name and ssn:\");
e5.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

Employee e6 = new Employee(\"Joann Rousch\", 333333.33, 1963);
System.out.println(\"Constructor with name, salary & hire date:\");
e6.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

Employee e7 = new Employee(\"Lucy Sharp\", 444444.44, \"987-65-4321\");
System.out.println(\"Constructor with name, salary & ssn:\");
e7.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

Employee e8 = new Employee(\"Pierre Sokolskis\", 1964, \"999-99-9999\");
System.out.println(\"Constructor with name, hire date & ssn:\");
e8.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

Employee e9 = new Employee(\"Last One\", 555.55, 1999,
\"888-88-8888\");
System.out.println(\"Constructor with name, salary, hire date, and ssn:\");
e9.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

// Test methods to change, return and write values
// change all
System.out.println(\"Before:\");
e9.writeOutput();
System.out.println();
System.out.println(\"After method to change all:\");
System.out.println();
e9.set(\"Changed Name\", 1010.10, 1010, \"101-10-1010\");
e9.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

// change name
e9.setName(\"Jekyl N. Hyde\");
System.out.println(\"After method to change name:\");
e9.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

// return name
System.out.println(\"Return method for name: \" + e9.getName());
System.out.println();
// write name
System.out.println(\"Write name method:\");
System.out.println();
e9.writeName();
System.out.println();
// change salary
System.out.println(\"Before:\");
e9.writeOutput();
System.out.println();
e9.setSalary(987.65);
System.out.println(\"After method to change salary:\");
e9.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

// return salary
System.out.println(\"Return method for salary: \" + e9.getSalary());
System.out.println();

// write salary
System.out.println(\"Write salary method:\");
System.out.println();
e9.writeSalary();
System.out.println();

// change hire date
System.out.println(\"Before:\");
e9.writeOutput();
System.out.println();
e9.setHireDate(2001);
System.out.println(\"After method to change hire date:\");
e9.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

// return hire date
System.out.println(\"Return method for hire date: \" + e9.getHireDate());
System.out.println();

// write hire date
System.out.println(\"Write hire date method:\");
System.out.println();
e9.writeHireDate();
System.out.println();

// change social security number
System.out.println(\"Before:\");
e9.writeOutput();
System.out.println();
e9.setSsn(\"777-77-7777\");
System.out.println(\"After method to change ssn:\");
e9.writeOutput();
System.out.println();
          System.out.println(\"===============================\");

// return social security number
System.out.println(\"Return method for ssn: \" + e9.getSsn());
System.out.println();

// write social security number
System.out.println(\"Write ssn method:\");
System.out.println();
e9.writeSsn();
System.out.println();

// test equals

// create e10 with the same vales as e9
// and it should test true
Employee e10 = new Employee(\"Jekyl N. Hyde\", 987.65, 2001, \"777-77-7777\");
System.out.println(\"Employee 9 data:\");
e9.writeOutput();
System.out.println();
System.out.println(\"Employee 10 data:\");
e10.writeOutput();
System.out.println();
if(e9.equals(e10))
System.out.println(\"TRUE: e9 equals e10!\");
else
System.out.println(\"FALSE: e9 does NOT equal e10.\");

System.out.println();
e10.setSsn(\"777-77-777\"); // create a single char difference
System.out.println(\"After changing just one character\"
+ \" in the social security number,\");
System.out.println(\"the data for the 2 employees are\");
System.out.println();
System.out.println(\"Employee 9 data:\");
e9.writeOutput();
System.out.println();
System.out.println(\"Employee 10 data:\");
e10.writeOutput();
System.out.println();
if(e9.equals(e10))
System.out.println(\"TRUE: e9 equals e10!\");
else
System.out.println(\"FALSE: e9 does NOT equal e10.\");

System.out.println(\"Do again? (Y for Yes, or N for No)\");
          repeat = keyboard.next().charAt(0);

} while((repeat == \'y\') || (repeat == \'Y\'));
      
}

}

Here are some screenshots of the output I am supposed to get. I really hope someone can help me.

Upload Assignment: H M × SampleRun.pdf Chegg Study | Guided Sc × 9 Java 7th Edition Textboo × R Facebook C https://bb.courses.maine.edu/courses/1/1710.UMS03-C.0006.1/content/-1873022-1/SampleRun.pdf jGRASP exec java EmployeeTest Using default constructor: Name No name yet. Salary: 0.0 Hire date: 1000 SSN000-00-0000 Using constructor with just name: Name Mondo Kane Salary 0.0 Hire date: 1000 SSN: 000-00-0000 Constructor with name & salary: Name Fleetis Pascal Hire date: 1000 SSN: 000-00-0000 Constructor with name and hire date: Name: Carl Wolf Salary 0.0 Hire date: 1968 SSN: 000-00-000 Constructor with name and ssn: Name: Sharon Kelly Salary: 0.0 Hire date: 1000 SSN: 123-45-6789 Constructor with name, salary & hire date: 11:15 AM 11/5/2016

Solution

public class Person {
   public String name;

   public Person() {
       name = \"No name yet.\";
   }

   public Person(String initialName) {
       name = initialName;
   }

   public void setName(String newName) {
       name = newName;
   }

   public String getName() {
       return name;
   }

   public void writeOutput() {
       System.out.println(\"Name: \" + name);
   }

   public boolean sameName(Person otherPerson) {
       return (this.name.equalsIgnoreCase(otherPerson.getName()));
   }

}

public class Employee extends Person {
   private double annualSalary;

   private int hiredYear;

   private String SSN;

   public Employee() {
       // TODO Auto-generated constructor stub
       super();
       this.annualSalary = 0.0;
       this.hiredYear = 1000;
       this.SSN = \"000-00-0000\";
   }

   public Employee(String initialName) {
       // TODO Auto-generated constructor stub
       super(initialName);
       this.annualSalary = 0.0;
       this.hiredYear = 1000;
       this.SSN = \"000-00-0000\";
   }

   public Employee(String initialName, double initialSalary) {
       // TODO Auto-generated constructor stub
       super(initialName);
       this.annualSalary = initialSalary;
       this.hiredYear = 1000;
       this.SSN = \"000-00-0000\";
   }

   public Employee(String initialName, int joinedYear) {
       // TODO Auto-generated constructor stub
       super(initialName);
       this.annualSalary = 0.0;
       this.hiredYear = joinedYear;
       this.SSN = \"000-00-0000\";
   }

   // constructors which include parameters such as employee name, salary and
   // hire date
   public Employee(String initialName, String id) {
       // TODO Auto-generated constructor stub
       super(initialName);
       this.annualSalary = 0.0;
       this.hiredYear = 1000;
       this.SSN = id;
   }

   public Employee(String initialName, double initialSalary, int joinedYear) {
       super(initialName);

       annualSalary = initialSalary;

       hiredYear = joinedYear;

       SSN = \"000-00-0000\";
   }

   public Employee(String initialName, double initialSalary, String id) {
       super(initialName);

       annualSalary = initialSalary;

       hiredYear = 1000;

       SSN = id;
   }

   public Employee(String initialName, int joinedYear, String id) {
       super(initialName);

       annualSalary = 0.0;

       hiredYear = joinedYear;

       SSN = id;
   }

   public Employee(String initialName, double initialSalary, int joinedYear,
           String id) {
       super(initialName);

       annualSalary = initialSalary;

       hiredYear = joinedYear;

       SSN = id;
   }

   // sets salary

   public void setSalary(double newSalary) {
       annualSalary = newSalary;
   }

   // sets year hired

   public void setHireDate(int year) {
       hiredYear = year;
   }

   // set employee ssn

   public void setSsn(String newSSN) {
       SSN = newSSN;
   }

   // return annual salary

   public double getSalary() {
       return annualSalary;
   }

   // return hired year

   public int getHireDate() {
       return hiredYear;
   }

   // return SSN

   public String getSsn() {
       return SSN;
   }

   // return true if both employee objects are the same. Otherwise return false

   public boolean equals(Employee otherEmployee) {
       if (name.equals(otherEmployee.name))

           if (annualSalary == otherEmployee.annualSalary)

               if (hiredYear == otherEmployee.hiredYear)

                   if (SSN == otherEmployee.SSN)

                       return true;

       return false;

   }

   public void set(String name, double salary, int joinedDate, String SSN) {
       this.setName(name);
       this.setSalary(salary);
       this.setHireDate(joinedDate);
       this.setSsn(SSN);

   }

   // prints employee name, annual salary, year hired and ID

   public void display() {
       System.out.println(\"Employee name: \" + name);
       System.out.println(\"Employee salary: \" + annualSalary);
       System.out.println(\"Employee hired year: \" + hiredYear);

       System.out.println(\"employee ssn: \" + SSN);
       System.out.println();
   }

   public void writeSalary() {
       // TODO Auto-generated method stub
       System.out.println(\"Employee salary: \" + annualSalary);

   }

   public void writeName() {
       // TODO Auto-generated method stub
       System.out.println(\"Employee name: \" + name);

   }

   public void writetHireDate() {
       // TODO Auto-generated method stub
       System.out.println(\"Employee hired year: \" + hiredYear);

   }

}

import java.util.*;

public class EmployeeTest {
   public static void main(String[] args) {
       Scanner keyboard = new Scanner(System.in);
       char repeat;
       do // repeat if user says \'yes\'
       {
           // Test the nine constructors (uses writeOutput method)
           Employee e1 = new Employee(); // default constructor
           System.out.println(\"Using default constructor:\");
           e1.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           Employee e2 = new Employee(\"Mondo Kane\");
           System.out.println(\"Using constructor with just name:\");
           e2.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           Employee e3 = new Employee(\"Fleetis Pascal\", 111111.11);
           System.out.println(\"Constructor with name & salary :\");
           e3.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");

           Employee e4 = new Employee(\"Carl Wolf\", 1968);
           System.out.println(\"Constructor with name and hire date:\");
           e4.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           Employee e5 = new Employee(\"Sharon Kelly\", \"123-45-6789\");
           System.out.println(\"Constructor with name and ssn:\");
           e5.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           Employee e6 = new Employee(\"Joann Rousch\", 333333.33, 1963);
           System.out.println(\"Constructor with name, salary & hire date:\");
           e6.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           Employee e7 = new Employee(\"Lucy Sharp\", 444444.44, \"987-65-4321\");
           System.out.println(\"Constructor with name, salary & ssn:\");
           e7.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           Employee e8 = new Employee(\"Pierre Sokolskis\", 1964, \"999-99-9999\");
           System.out.println(\"Constructor with name, hire date & ssn:\");
           e8.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           Employee e9 = new Employee(\"Last One\", 555.55, 1999, \"888-88-8888\");
           System.out
                   .println(\"Constructor with name, salary, hire date, and ssn:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           // Test methods to change, return and write values
           // change all
           System.out.println(\"Before:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"After method to change all:\");
           System.out.println();
           e9.set(\"Changed Name\", 1010.10, 1010, \"101-10-1010\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           // change name
           e9.setName(\"Jekyl N. Hyde\");
           System.out.println(\"After method to change name:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           // return name
           System.out.println(\"Return method for name: \" + e9.getName());
           System.out.println();
           // write name
           System.out.println(\"Write name method:\");
           System.out.println();
           e9.writeName();
           System.out.println();
           // change salary
           System.out.println(\"Before:\");
           e9.writeOutput();
           System.out.println();
           e9.setSalary(987.65);
           System.out.println(\"After method to change salary:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           // return salary
           System.out.println(\"Return method for salary: \" + e9.getSalary());
           System.out.println();
           // write salary
           System.out.println(\"Write salary method:\");
           System.out.println();
           e9.writeSalary();
           System.out.println();
           // change hire date
           System.out.println(\"Before:\");
           e9.writeOutput();
           System.out.println();
           e9.setHireDate(2001);
           System.out.println(\"After method to change hire date:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           // return hire date
           System.out.println(\"Return method for hire date: \"
                   + e9.getHireDate());
           System.out.println();
           // write hire date
           System.out.println(\"Write hire date method:\");
           System.out.println();
           e9.writetHireDate();
           System.out.println();
           // change social security number
           System.out.println(\"Before:\");
           e9.writeOutput();
           System.out.println();
           e9.setSsn(\"777-77-7777\");
           System.out.println(\"After method to change ssn:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"===============================\");
           // return social security number
           System.out.println(\"Return method for ssn: \" + e9.getSsn());
           System.out.println();
           // write social security number
           System.out.println(\"Write ssn method:\");
           System.out.println();
           e9.writeName();
           System.out.println();
           // test equals
           // create e10 with the same vales as e9
           // and it should test true
           Employee e10 = new Employee(\"Jekyl N. Hyde\", 987.65, 2001,
                   \"777-77-7777\");
           System.out.println(\"Employee 9 data:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"Employee 10 data:\");
           e10.writeOutput();
           System.out.println();
           if (e9.equals(e10))
               System.out.println(\"TRUE: e9 equals e10!\");
           else
               System.out.println(\"FALSE: e9 does NOT equal e10.\");
           System.out.println();
           e10.setSsn(\"777-77-777\"); // create a single char difference
           System.out.println(\"After changing just one character\"
                   + \" in the social security number,\");
           System.out.println(\"the data for the 2 employees are\");
           System.out.println();
           System.out.println(\"Employee 9 data:\");
           e9.writeOutput();
           System.out.println();
           System.out.println(\"Employee 10 data:\");
           e10.writeOutput();
           System.out.println();
           if (e9.equals(e10))
               System.out.println(\"TRUE: e9 equals e10!\");
           else
               System.out.println(\"FALSE: e9 does NOT equal e10.\");
           System.out.println(\"Do again? (Y for Yes, or N for No)\");
           repeat = keyboard.next().charAt(0);
       } while ((repeat == \'y\') || (repeat == \'Y\'));

   }
}

OUTPUT:

Using default constructor:
Name: No name yet.

===============================
Using constructor with just name:
Name: Mondo Kane

===============================
Constructor with name & salary :
Name: Fleetis Pascal

===============================
Constructor with name and hire date:
Name: Carl Wolf

===============================
Constructor with name and ssn:
Name: Sharon Kelly

===============================
Constructor with name, salary & hire date:
Name: Joann Rousch

===============================
Constructor with name, salary & ssn:
Name: Lucy Sharp

===============================
Constructor with name, hire date & ssn:
Name: Pierre Sokolskis

===============================
Constructor with name, salary, hire date, and ssn:
Name: Last One

===============================
Before:
Name: Last One

After method to change all:

Name: Changed Name

===============================
After method to change name:
Name: Jekyl N. Hyde

===============================
Return method for name: Jekyl N. Hyde

Write name method:

Employee name: Jekyl N. Hyde

Before:
Name: Jekyl N. Hyde

After method to change salary:
Name: Jekyl N. Hyde

===============================
Return method for salary: 987.65

Write salary method:

Employee salary: 987.65

Before:
Name: Jekyl N. Hyde

After method to change hire date:
Name: Jekyl N. Hyde

===============================
Return method for hire date: 2001

Write hire date method:

Employee hired year: 2001

Before:
Name: Jekyl N. Hyde

After method to change ssn:
Name: Jekyl N. Hyde

===============================
Return method for ssn: 777-77-7777

Write ssn method:

Employee name: Jekyl N. Hyde

Employee 9 data:
Name: Jekyl N. Hyde

Employee 10 data:
Name: Jekyl N. Hyde

TRUE: e9 equals e10!

After changing just one character in the social security number,
the data for the 2 employees are

Employee 9 data:
Name: Jekyl N. Hyde

Employee 10 data:
Name: Jekyl N. Hyde

FALSE: e9 does NOT equal e10.
Do again? (Y for Yes, or N for No)
N

Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr
Hi, I need help with a java programming project. specifically practice Program number 1 on page 662 from chapter 7 of the 7th edition of the book , java:an intr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site