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

Write a java program that keeps track of Employees, Students and visitors. The a

ID: 3603215 • Letter: W

Question

Write a java program that keeps track
of Employees, Students and visitors. The address for all employees and students must be
recorded by the system. For an address to be valid it must have the following attributes, street,
city and parish. Employee attributes that the user must enter into the system is First name, last name, gender and address. The students attributes must be First name , last name, gender, Date of birth. The visitors attributes must be first name, last name date of visit and time of visit. There are two types of employees Regular and Teachers, express this information in an enumerated class. Regular employees are paid a gross of $100,000.00 monthly and teachers are paid at a rate of $2,100.00 Per hour. Teachers work a maximum 25 paid hours per week and deliver no more than 4 subjects per academic year. If a teacher is delivering more than 3
subjects they will receive an additionally $3,000.00 weekly. If the employee is a teacher the
system must calculate and display the gross weekly amount earned, otherwise just display the gross as stated. Then Create an abstract super class called Individual so that employees, students and visitors can derived the common attributes. students and visitors cannot be inherited by any other entity.

Use an interface to declare the following methods printDetails() and printDetails(Individual per).
The contact details (name, telephone number and email address) for the school must also be
incorporated in the interface. Use another interface to declare a method called
calcGrossSalary(). This method must be implemented by the employees entity. Not all the students pursue the same number of subjects. Some may pursue 1, 2, 3, 4 or more
subjects, Use regular arrays to implement this functionality.
All printed output must include the institution's name and contact details.
Crete a driver class (a class with a main method) to test the logics of your program.

Explanation / Answer

public class Employee implements Comparable<Employee>

{

private String ssn;

private String lastName;

private String firstName;

public int compareTo(Employee emp)

{

int compLasts = lastName.compareTo(emp.lastName);

int compFirsts = firstName.compareTo(emp.firstName);

int compSSN = ssn.compareTo(emp.ssn);

if ((compSSN != 0) && (compLasts != 0) && (compFirsts != 0))

{

return compLasts;

}

else

{

throw new IllegalArgumentException("Empolyee already exists with that SSN.");

}

}

public Employee (String socialSN, String ln, String fn)

{

ssn = socialSN;

lastName = ln;

firstName = fn;

}

public String toString()

{

return "Employee[SSN= " + ssn + ", Last Name= " + lastName + ", First Name= " + firstName + "]";

}

public String getLastName()

{

return lastName;

}

public String getFirstName()

{

return firstName;

}

public String getSSN()

{

return ssn;

}

public void setLastName(String setLN)

{

lastName = setLN;

}

public void setFirstName(String setFN)

{

firstName = setFN;

}

public void setSSN(String setSSN)

{

ssn = setSSN;

}

}

Raw

HMandTS_Tester.java

//HMandTS_Tester - Jimmy Kurian

import java.util.Scanner;

import java.util.*;

public class HMandTS_Tester

{

public static int menu()

{

System.out.println("Choose one option from following : ");

System.out.println("1) Add a new employee.");

System.out.println("2) Delete an employee via SSN.");

System.out.println("3) Retrive an employee via SSN.");

System.out.println("4) List all employees.");

System.out.println("5) Exit.");

Scanner sc = new Scanner(System.in);

return sc.nextInt();

}

public static void main(String[] args)

{

HashMap<String, Employee> employeesByKey = new HashMap<String, Employee>();

TreeSet<Employee> employeesByName = new TreeSet<Employee>();

int menuStore = menu();

while(menuStore != 5)

{

System.out.println();

switch (menuStore)

{

case 1:

Scanner input1 = new Scanner(System.in);

System.out.println("Enter a SSN: ");

String str1 = input1.nextLine();

System.out.println("Enter Last Name: ");

String str2 = input1.nextLine();

System.out.println("Enter First Name: ");

String str3 = input1.nextLine();

Employee newEmp = new Employee(str1, str2, str3);

employeesByKey.put(newEmp.getSSN(), newEmp);

employeesByName.add(newEmp);

System.out.println();

break;

case 2:

Scanner input2 = new Scanner(System.in);

System.out.println("Please enter the SSN of the employee you wish to delete: ");

String delStr = input2.nextLine();

if(employeesByKey.containsKey(delStr))

{

employeesByKey.remove(delStr);

Iterator<Employee> iterator;

iterator = employeesByName.iterator();

while (iterator.hasNext())

{

Employee iterEmp = iterator.next();

if (delStr.compareTo(iterEmp.getSSN()) == 0)

{

iterator.remove();

}

}

System.out.println("Employee removed.");

System.out.println("");

}

else

{

System.out.println("No such SSN.");

System.out.println("");

}

break;

case 3:

Scanner input3 = new Scanner(System.in);

System.out.println("Please enter the SSN of the employee you wish to retrive: ");

String retStr = input3.nextLine();

if(employeesByKey.containsKey(retStr))

{

Employee recievedEmployee = employeesByKey.get(retStr);

System.out.println(recievedEmployee);

System.out.println("");

}

else

{

System.out.println("No such SSN.");

System.out.println("");

}

break;

case 4:

Iterator iterator;

iterator = employeesByName.iterator();

if (employeesByName.isEmpty())

{

System.out.print("Tree Set is empty.");

}

else

{

while (iterator.hasNext())

{

System.out.print(iterator.next() + " ");

}

}

System.out.println("");

break;

case 5:

break;

}

menuStore = menu();

}

}

}

package student;
import java.util.*;

public class Student {


public static void main(String[] args) {
int i, q, z, c, b;
int x=0;
String[] name = new String[30];
int[] age = new int[30];
String[] course = new String[30];
String[] year = new String[30];
String[] section = new String[30];
int menuChoice;

Scanner input = new Scanner (System.in);

start:
do{

System.out.println(" Student Record Menu");
System.out.println(" 1. Add Student 2. View Students 3. Search Student 4. Exit");
System.out.println("Enter a choice: ");
menuChoice = input.nextInt();

if (menuChoice==1)
{
for (z=x; z<=29; z++)
{
System.out.println("Full name:");
name [z] = input.nextLine();
System.out.println("Age:");
age [z] = input.nextInt();
System.out.println("Course:");
course [z] = input.next();
System.out.println("Year:");
year [z] = input.next();
System.out.println("Section:");
section [z] = input.next();
x++;
continue start;
}
}
else if (menuChoice==2)
{
for (i=0; i<x; i++)
{
System.out.println(name[i] + age [i] + course [i] + year [i] + section [i]);
}
}

} while (menuChoice<4);

}
}

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