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

The Person, Student, Employee, Faculty and Staff classes: 1.) Design a Person cl

ID: 3906043 • Letter: T

Question

The Person, Student, Employee, Faculty and Staff classes:

1.) Design a Person class: has a name, address, phone number and email address.

2.) Subclass Student (of Person): Status(Freshman, Sophomore, Junior, or Senior)-Define as a constant

3.) Subclass Employee (of Person): has an Office number, salary, date hired (Use a Date Object for this)

4.) Subclass Faculty (of Employee): has office hours and rank (Professor, Associate Professor, Assistant Professor, Instructor)

5.) Subclass Staff (of Employee): has a title

Override the toString method to output the correct information about each object

Explanation / Answer

import java.util.*;

class MyDate {
   private String date;

   public MyDate(String date){
       this.date = date;
   }

    public String getDate() {
       return date;
   }

}
class Person
{
private String pname;
private String address;
private String phone;
private String email;


public Person(String pname,String address,String phone,String email)
{
this.pname = pname;
this.address = address;
this.phone = phone;
this.email = email;
}
public String toString()
{
return " "+pname +" Address : "+address+" Phone number : "+phone + " Email address : "+email;
}
}
class Employee extends Person
{
private int office;
private int salary;
private MyDate hiredate;

public Employee(String name,String address,String phone,String email,int office,int salary,MyDate hiredate)
{
super(name,address,phone,email);
this.office = office;
this.salary = salary;
this.hiredate = hiredate;
}
public String toString()
{

return super.toString()+"Office Number : "+office +" Salary : "+salary +" hiredate : "+hiredate;
}
}
class Faculty extends Employee
{

private String officeHours;
private String rank;

public Faculty(String name,String address,String phone,String email,int office,int salary,MyDate hiredate,String officehours,String rank)
{
super(name,address,phone,email,office,salary,hiredate);
this.officeHours = officeHours;
this.rank = rank;
}
public String toString()
{

return " "+super.toString()+ "Office Hours : "+officeHours +" Rank : "+rank;
}
}
class Student extends Person
{
private String status;


public Student(String name,String address,String phone,String email,String status)
{
super(name,address,phone,email);
this.status = status;
}
public String toString()
{

return super.toString()+" Status : "+status;
}
}

class Staff extends Employee
{
private String title;
public Staff(String name,String address,String phone,String email,int office,int salary,MyDate hiredate,String title)
{
super(name,address,phone,email,office,salary,hiredate);
this.title = title;
}
public String toString()
{

return " "+super.toString()+ "Title : "+title;
}
}
class Test
{
   public static void main (String[] args)
   {
   String pname,address,phone,email,status,rank,title,officeHours,hiredate;
   int office,salary;
   Scanner input = new Scanner(System.in);
   System.out.println("1.To create a Student");
   System.out.println("1.To create an Employee");
   System.out.println("choice : ");
   int choice = input.nextInt();
System.out.println("Enter a name : ");
   pname = input.nextLine();
   System.out.println("----------Name"+pname);
   System.out.println("Enter "+pname+" address : ");
   address = input.nextLine();
   System.out.println("Enter "+pname+" phone : ");
   phone = input.nextLine();
   System.out.println("Enter "+pname+" email : ");
   email = input.nextLine();
   if(choice == 1)
   {
  
   System.out.println("Enter "+pname+" class Status : ");
   status = input.nextLine();
  
   Student s = new Student(pname,address,phone,email,status);
   System.out.println(s.toString());
   }
   else if(choice == 2)
   {
  
   System.out.println("1.To create a faculty member");
System.out.println("2.To create a Staff member");
System.out.println("choice : ");
choice = input.nextInt();
if(choice == 1)
{
System.out.println("Enter office number : ");
office = input.nextInt();
System.out.println("Enter salary : ");
salary = input.nextInt();
System.out.println("Enter hire date(mm/dd/yyyy) : ");
hiredate = input.nextLine();
MyDate d = new MyDate(hiredate);
System.out.println("Enter office hours : ");
officeHours = input.nextLine();
System.out.println("Enter rank : ");
rank = input.nextLine();
}
else if(choice == 2)
{
System.out.println("Enter office number : ");
System.out.println("Enter salary : ");
System.out.println("Enter hire date(mm/dd/yyyy) : ");
System.out.println("Enter title : ");
}

   }
   }
}

Output:

1.To create a Student
2.To create an Employee
choice :1
Enter a name :John
----------Name
Enter address :456.Down Street
Enter phone :766-57687
Enter email :john@mail.com
Enter class Status :Senior


Address : john
Phone number : 456.Down Street
Email address : 766-57687
Status : john@mail.com

Do ask if any doubt. Please upvote

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote