Question
public class Date { // variables private int year; private int month; private int day; // constructor public Date(int theYear, int theMonth, int theDay) {
public class Date { // variables private int year; private int month; private int day; // constructor public Date(int theYear, int theMonth, int theDay) { setYear(theYear); setMonth(theMonth); setDay(theDay); } // setters public void setYear(int theYear) { year = theYear; } public void setMonth(int theMonth) { // only allow months between 1 and 12 if(theMonth>=1 && theMonth days[month] ){ day = 1; } else { day = theDay; } } public String toString() { String result = ""; result = year+"/"+month+"/"+day; return result; } }
public abstract class Person { //variables private String lastName; private String firstName; private char middleInit; private Date birthDate; //Constructors public Person(){}; public Person(String itsLastName, String itsFirstName, char itsMiddleInit, Date itsBirthDate){ lastName = itsLastName; firstName = itsFirstName; middleInit = itsMiddleInit; birthDate = itsBirthDate; } //getters public String getLastName(){ return lastName; } public String getFirstName(){ return firstName; } public char getMiddleInit(){ return middleInit; } public Date getBirthDate(){ return birthDate; } //setters public void setLastName(String itsLastName){ lastName = itsLastName; } public void setFirstName(String itsFirstName){ firstName = itsFirstName; } public void setMiddleInit(char itsMiddleInit){ middleInit = itsMiddleInit; } public void setBirthDate(Date itsBirthDate){ birthDate = itsBirthDate; } //returns full name in "[firstname], [lastname] [middleinit]." format public String getFullName() { String result = ""; result = firstName+", "+lastName+" "+middleInit+"."; return result; } public abstract String toString(); }
public class Employee extends Person{ int employeeNo; float monthlySalary; Date hireDate; public Employee(String itsfirstName,String itslastName,char itsmiddleInit , Date itsbirthDate ,int itsemployeeNo , float itsmonthlySalary ,Date itshireDate ) { super(itsfirstName,itslastName,itsmiddleInit,itsbirthDate); employeeNo=itsemployeeNo; monthlySalary=itsmonthlySalary; hireDate = itshireDate; } public Employee(){};
public void setEmployeeNo( int itsemployeeNo ){employeeNo=itsemployeeNo;}
public int getEmployeeNo(){ return employeeNo;}
public void setmonthlySalary( float itsmonthlySalary ){monthlySalary=itsmonthlySalary;}
public float getmonthlySalary(){ return monthlySalary;}
public void sethireDate( Date itshireDate ){hireDate=itshireDate;}
public Date gethireDate(){ return hireDate;}
public String toString(){ String result=""; result="Employee No: " +employeeNo + " Full Name " +getFullName()+ " Birth Date " +getBirthDate()+ " Monthly Salary" +monthlySalary ; return result; } }
Can anyone help me in Question -5
- Display info for employee by employee number prompts the user for an employee number, and searches the array for an employee with that employee number. If one is found it is displayed, if not a record not found message is printed to the screen.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started