Question: public class Person { // person name protected String name; // defualt constructor public Person() { name =No Name Yet; } // 1st argument constructors

public class Person
{
// person name
protected String name;

// defualt constructor
public Person()
{
name ="No Name Yet";
}

// 1st argument constructors
public Person(String initialName)
{
name = initialName;
}

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

//Returns person name
public String getName()
{
return name;
}

// inputs name to console
public void writeOutput()
{
System.out.println("Name : " + name);
}

//returns true in names are the same if not false
public boolean hasSameName(Person otherPerson)
{
return
this.name.equalsIgnoreCase(otherPerson.name);
}


}




// employee
public class Employee extends Person
{
//data members
private double annualSalary;
private int hiredYear;
private String ID;

// constructor with parameters
public Employee(String initialName, double initialSalary, int joinedYear, String id)
{
super(initialName);
annualSalary = initialSalary;
hiredYear = joinedYear;
ID = id;
}

//sets annual salary
public void setAnnualSalary(double newSalary)
{
annualSalary = newSalary;
}

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

//sets employee id
public void setID(String newID)
{
ID =newID;
}

//returns annual salary
public double getAnnualSalary()
{
return annualSalary;
}

//returns hired year
public int getHiredYear()
{
return hiredYear;
}

// returns employee id
public String getID()
{
return ID;
}

public boolean equals(Employee otherEmployee)
{
if (name.equals(otherEmployee.name))
if (annualSalary == otherEmployee.annualSalary)
if(hiredYear == otherEmployee.hiredYear)
if(ID == otherEmployee.ID)
return true;
return false;
}

//prints the employee name salary hired yr and id
public void display()
{
System.out.println("Employee Name: " + name);
System.out.println("Employee Annual Salary: " + annualSalary);
System.out.println("Employee Hired Year: " + hiredYear);
System.out.println("Employee ID: " + ID);
System.out.println();

}


}

--------------------------------------------------------------------------------------------------------------------------------

public class TestEmployee
{
public static void main (String[] args)
{
// employee objects

Employee e1 = new Employee("John", 50000, 2004, "A101");
e1.display();
}

}

______________________________________________________________________

instead of inputing the data i want to beable to have the user input it all would like someone to help me with the coding to allow the

user to do so

Step by Step Solution

3.50 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To modify the code so that the user can input employee data instead of hardcoding it you can use the Scanner class in Java to read inputs from the con... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!