SlideShare a Scribd company logo
1 of 21
Download to read offline
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

More Related Content

Similar to Hi, I need help with a java programming project. specifically practi.pdf

Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfankitmobileshop235
 
In your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdfIn your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdfarihanthtextiles
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdffeelingspaldi
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docxajoy21
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfallystraders
 
First compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfFirst compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfaoneonlinestore1
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfcalderoncasto9163
 
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdfThe solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdfaparnatiwari291
 
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdfSpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdfezonesolutions
 
Spock Framework - Slidecast
Spock Framework - SlidecastSpock Framework - Slidecast
Spock Framework - SlidecastDaniel Kolman
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective JavaScalac
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxwhitneyleman54422
 
You will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdfYou will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdfjeetumordhani
 
Week 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhereWeek 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhereMitchell Wand
 

Similar to Hi, I need help with a java programming project. specifically practi.pdf (20)

Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdf
 
In your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdfIn your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdf
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdf
 
2. Create a Java class called EmployeeMain within the same project Pr.docx
 2. Create a Java class called EmployeeMain within the same project Pr.docx 2. Create a Java class called EmployeeMain within the same project Pr.docx
2. Create a Java class called EmployeeMain within the same project Pr.docx
 
I Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdfI Have the following Java program in which converts Date to Words an.pdf
I Have the following Java program in which converts Date to Words an.pdf
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
First compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdfFirst compile all the classes.But to run the program we have to run .pdf
First compile all the classes.But to run the program we have to run .pdf
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
 
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdfThe solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
The solution is as belowEmployeeDemo.javaimport java.util.Scann.pdf
 
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdfSpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf
 
Structures and Unions
Structures and UnionsStructures and Unions
Structures and Unions
 
Spock Framework - Slidecast
Spock Framework - SlidecastSpock Framework - Slidecast
Spock Framework - Slidecast
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
 
4.3 Hibernate example.docx
4.3 Hibernate example.docx4.3 Hibernate example.docx
4.3 Hibernate example.docx
 
yash shakya.pptx
yash shakya.pptxyash shakya.pptx
yash shakya.pptx
 
ACP Java Assignment.pdf
ACP Java Assignment.pdfACP Java Assignment.pdf
ACP Java Assignment.pdf
 
You will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdfYou will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdf
 
Week 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhereWeek 03 Lesson 02 recursive data definitions everywhere
Week 03 Lesson 02 recursive data definitions everywhere
 

More from fashioncollection2

All programming assignments should include the name, or names, of th.pdf
All programming assignments should include the name, or names, of th.pdfAll programming assignments should include the name, or names, of th.pdf
All programming assignments should include the name, or names, of th.pdffashioncollection2
 
After a (not very successful) trick or treating round, Candice has 1.pdf
After a (not very successful) trick or treating round, Candice has 1.pdfAfter a (not very successful) trick or treating round, Candice has 1.pdf
After a (not very successful) trick or treating round, Candice has 1.pdffashioncollection2
 
Why steroids can cross the cell membraneWhy steroids can cross .pdf
Why steroids can cross the cell membraneWhy steroids can cross .pdfWhy steroids can cross the cell membraneWhy steroids can cross .pdf
Why steroids can cross the cell membraneWhy steroids can cross .pdffashioncollection2
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdffashioncollection2
 
Write a command in unixlinux to Display all the files whose names e.pdf
Write a command in unixlinux to Display all the files whose names e.pdfWrite a command in unixlinux to Display all the files whose names e.pdf
Write a command in unixlinux to Display all the files whose names e.pdffashioncollection2
 
Why is “Profit” a problematic target Please consider in your answer.pdf
Why is “Profit” a problematic target Please consider in your answer.pdfWhy is “Profit” a problematic target Please consider in your answer.pdf
Why is “Profit” a problematic target Please consider in your answer.pdffashioncollection2
 
Which of the following statements about protists is falsea) There a.pdf
Which of the following statements about protists is falsea) There a.pdfWhich of the following statements about protists is falsea) There a.pdf
Which of the following statements about protists is falsea) There a.pdffashioncollection2
 
Which cable type would be used to connect a router to a switchA. .pdf
Which cable type would be used to connect a router to a switchA. .pdfWhich cable type would be used to connect a router to a switchA. .pdf
Which cable type would be used to connect a router to a switchA. .pdffashioncollection2
 
What is the role of abiotic factors in the formation of biomesS.pdf
What is the role of abiotic factors in the formation of biomesS.pdfWhat is the role of abiotic factors in the formation of biomesS.pdf
What is the role of abiotic factors in the formation of biomesS.pdffashioncollection2
 
What information needs to be encoded in a loadstorebranchALU inst.pdf
What information needs to be encoded in a loadstorebranchALU inst.pdfWhat information needs to be encoded in a loadstorebranchALU inst.pdf
What information needs to be encoded in a loadstorebranchALU inst.pdffashioncollection2
 
What are the major terrestrial adaptations of plants1- List the F.pdf
What are the major terrestrial adaptations of plants1- List the F.pdfWhat are the major terrestrial adaptations of plants1- List the F.pdf
What are the major terrestrial adaptations of plants1- List the F.pdffashioncollection2
 
The total lung capacity of a patient is 5.5 liters. Find the patient.pdf
The total lung capacity of a patient is 5.5 liters. Find the patient.pdfThe total lung capacity of a patient is 5.5 liters. Find the patient.pdf
The total lung capacity of a patient is 5.5 liters. Find the patient.pdffashioncollection2
 
The insatiable demand for everything wireless, video, and Web-enable.pdf
The insatiable demand for everything wireless, video, and Web-enable.pdfThe insatiable demand for everything wireless, video, and Web-enable.pdf
The insatiable demand for everything wireless, video, and Web-enable.pdffashioncollection2
 
Technology is an ever-growing system that provides advantages and in.pdf
Technology is an ever-growing system that provides advantages and in.pdfTechnology is an ever-growing system that provides advantages and in.pdf
Technology is an ever-growing system that provides advantages and in.pdffashioncollection2
 
Suppose that the proportions of blood phenotypes in a particular pop.pdf
Suppose that the proportions of blood phenotypes in a particular pop.pdfSuppose that the proportions of blood phenotypes in a particular pop.pdf
Suppose that the proportions of blood phenotypes in a particular pop.pdffashioncollection2
 
Select all of the following that are true regarding evolution. Altho.pdf
Select all of the following that are true regarding evolution.  Altho.pdfSelect all of the following that are true regarding evolution.  Altho.pdf
Select all of the following that are true regarding evolution. Altho.pdffashioncollection2
 
Role of involvement in consumer decision-making. Identify the level .pdf
Role of involvement in consumer decision-making. Identify the level .pdfRole of involvement in consumer decision-making. Identify the level .pdf
Role of involvement in consumer decision-making. Identify the level .pdffashioncollection2
 
Questionsa What are some of the barriers to understanding an issu.pdf
Questionsa What are some of the barriers to understanding an issu.pdfQuestionsa What are some of the barriers to understanding an issu.pdf
Questionsa What are some of the barriers to understanding an issu.pdffashioncollection2
 
Rainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdf
Rainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdfRainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdf
Rainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdffashioncollection2
 
Quality software project managementHow are tasks, activities, and .pdf
Quality software project managementHow are tasks, activities, and .pdfQuality software project managementHow are tasks, activities, and .pdf
Quality software project managementHow are tasks, activities, and .pdffashioncollection2
 

More from fashioncollection2 (20)

All programming assignments should include the name, or names, of th.pdf
All programming assignments should include the name, or names, of th.pdfAll programming assignments should include the name, or names, of th.pdf
All programming assignments should include the name, or names, of th.pdf
 
After a (not very successful) trick or treating round, Candice has 1.pdf
After a (not very successful) trick or treating round, Candice has 1.pdfAfter a (not very successful) trick or treating round, Candice has 1.pdf
After a (not very successful) trick or treating round, Candice has 1.pdf
 
Why steroids can cross the cell membraneWhy steroids can cross .pdf
Why steroids can cross the cell membraneWhy steroids can cross .pdfWhy steroids can cross the cell membraneWhy steroids can cross .pdf
Why steroids can cross the cell membraneWhy steroids can cross .pdf
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
 
Write a command in unixlinux to Display all the files whose names e.pdf
Write a command in unixlinux to Display all the files whose names e.pdfWrite a command in unixlinux to Display all the files whose names e.pdf
Write a command in unixlinux to Display all the files whose names e.pdf
 
Why is “Profit” a problematic target Please consider in your answer.pdf
Why is “Profit” a problematic target Please consider in your answer.pdfWhy is “Profit” a problematic target Please consider in your answer.pdf
Why is “Profit” a problematic target Please consider in your answer.pdf
 
Which of the following statements about protists is falsea) There a.pdf
Which of the following statements about protists is falsea) There a.pdfWhich of the following statements about protists is falsea) There a.pdf
Which of the following statements about protists is falsea) There a.pdf
 
Which cable type would be used to connect a router to a switchA. .pdf
Which cable type would be used to connect a router to a switchA. .pdfWhich cable type would be used to connect a router to a switchA. .pdf
Which cable type would be used to connect a router to a switchA. .pdf
 
What is the role of abiotic factors in the formation of biomesS.pdf
What is the role of abiotic factors in the formation of biomesS.pdfWhat is the role of abiotic factors in the formation of biomesS.pdf
What is the role of abiotic factors in the formation of biomesS.pdf
 
What information needs to be encoded in a loadstorebranchALU inst.pdf
What information needs to be encoded in a loadstorebranchALU inst.pdfWhat information needs to be encoded in a loadstorebranchALU inst.pdf
What information needs to be encoded in a loadstorebranchALU inst.pdf
 
What are the major terrestrial adaptations of plants1- List the F.pdf
What are the major terrestrial adaptations of plants1- List the F.pdfWhat are the major terrestrial adaptations of plants1- List the F.pdf
What are the major terrestrial adaptations of plants1- List the F.pdf
 
The total lung capacity of a patient is 5.5 liters. Find the patient.pdf
The total lung capacity of a patient is 5.5 liters. Find the patient.pdfThe total lung capacity of a patient is 5.5 liters. Find the patient.pdf
The total lung capacity of a patient is 5.5 liters. Find the patient.pdf
 
The insatiable demand for everything wireless, video, and Web-enable.pdf
The insatiable demand for everything wireless, video, and Web-enable.pdfThe insatiable demand for everything wireless, video, and Web-enable.pdf
The insatiable demand for everything wireless, video, and Web-enable.pdf
 
Technology is an ever-growing system that provides advantages and in.pdf
Technology is an ever-growing system that provides advantages and in.pdfTechnology is an ever-growing system that provides advantages and in.pdf
Technology is an ever-growing system that provides advantages and in.pdf
 
Suppose that the proportions of blood phenotypes in a particular pop.pdf
Suppose that the proportions of blood phenotypes in a particular pop.pdfSuppose that the proportions of blood phenotypes in a particular pop.pdf
Suppose that the proportions of blood phenotypes in a particular pop.pdf
 
Select all of the following that are true regarding evolution. Altho.pdf
Select all of the following that are true regarding evolution.  Altho.pdfSelect all of the following that are true regarding evolution.  Altho.pdf
Select all of the following that are true regarding evolution. Altho.pdf
 
Role of involvement in consumer decision-making. Identify the level .pdf
Role of involvement in consumer decision-making. Identify the level .pdfRole of involvement in consumer decision-making. Identify the level .pdf
Role of involvement in consumer decision-making. Identify the level .pdf
 
Questionsa What are some of the barriers to understanding an issu.pdf
Questionsa What are some of the barriers to understanding an issu.pdfQuestionsa What are some of the barriers to understanding an issu.pdf
Questionsa What are some of the barriers to understanding an issu.pdf
 
Rainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdf
Rainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdfRainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdf
Rainfall Intensity Duration Frequency Graph ear Reture Period torm Du.pdf
 
Quality software project managementHow are tasks, activities, and .pdf
Quality software project managementHow are tasks, activities, and .pdfQuality software project managementHow are tasks, activities, and .pdf
Quality software project managementHow are tasks, activities, and .pdf
 

Recently uploaded

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Hi, I need help with a java programming project. specifically practi.pdf

  • 1. 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) {
  • 2. 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
  • 3. 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
  • 4. 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()
  • 5. { 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();
  • 6. 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:");
  • 7. 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:");
  • 8. 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();
  • 9. 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')); }
  • 10. } 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 {
  • 11. 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);
  • 12. 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;
  • 13. } // 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);
  • 14. 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);
  • 15. 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
  • 16. // 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();
  • 17. // 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
  • 18. 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)");
  • 19. 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
  • 20. =============================== 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!
  • 21. 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