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

Java Program Help: 1. Create an employee Class that encapsulates the concept of

ID: 3854860 • Letter: J

Question

Java Program Help:

1. Create an employee Class that encapsulates the concept of an employee. The attributes of an employee are: - id o a random integer in the range 0 to 99999999 (i.e. like a social security number) o we will ignore the fact that we may get duplicate id numbers - name o a String of a random length between 5 and 10 characters (inclusive) made up of a random set of lower case characters - dept o a random integer in the range 1 to 5 (inclusive) - hired o a random integer in the range 1995 to 2015 (inclusive) You may also want to create a factory method that allows you to generate a new employee with random attributes.

2.Create a class named Sort that will act as a container for the following generic array sorting algorithms: - simpleBubbleSort o a brute force bubble sort that just uses a pair of nested loops o this needs to be a generic bubble sort o this needs to be a stable sort - mergeSort o this should be the recursive mergeSort described in the textbook - quickSort o this should be the recursive quickSort described in the textbook o you may have to modify this code - multikeySort o this should be a generic sort o the multikeySort should be able to support between two and four keys o the first parameter in the parameter list should be the array being sorted. o the remaining parameters in the parameter list should be the keys (Comparators), ordered left to right from most significant to least significant.

3. - Create a client class that o Generates an array of 1,000,000 employees o Sort the employee array on name using the merge sort o Sort the employee array on dept using the quick sort o Sort the employee array on id using the bubble sort Reduce the array size to 100,000 for the bubble sort. A list of 1,000,000 employees can take 6 plus hours to sort with the bubble sort. o Sort the employee array using the multikey sort so that All employees are sorted by department Within a department grouping all the employees are sorted by hire date Within a department and hire date grouping all the employees are sorted by their name - Since the list of employees is long o You will not print out the unsorted or sorted employee lists, instead, o Print out the time that it takes to run each sort o Suggestion: Make a test run of 1,000 employees and inspect the results to make sure that they are correctly ordered before attempting the full test.

Thanks for the Help

Explanation / Answer

package company;

import java.util.Random;

//class employee

public class Employee{

                     public static int id;

                     public static String name;

                     public static int dept;

                     public static int hired;

                     public int getid();

                     public String getname;

                    public int getdept();   

                    public int gethired();  

} //end employee class

public abstract class AbstractFactory {

                    abstract public int getid();

                    abstract public String getname;

                   abstract public int getdept();   

                   abstract public int gethired();            

}

public class EmployeeFactory extends AbstractFactory {    

            public int getid()  {  

                 Random rand = new Random();

                  public static int emp_id=rand.nextInt(1000000000);

                 return emp_id }

              //string name

public String getname() {  

                 public static String name;

                 char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();

                StringBuilder sb = new StringBuilder();

                 Random rand2 = new Random();

                for (int i = 0; i < 20; i++) {

                                                      char c = chars[random2.nextInt(chars.length)];

                                                     sb.append(c); }

                name = sb.toString();

return name;

}

             public int getdept(){

       Random rand1 = new Random();

                rand1 = 1 + (int)(Math.random() * 5);

                public static dept=rand1;

return dept;

}

                  // hired variable

             public int gethired(){

                Random rand3 = new Random();

                rand3 = 1995 + (int)(Math.random() * 2005);

                public static hired = rand3;

return hired;

}

}

public class client()    {   

public static void main(String args[]){

// array of 1000 employess

Employee[] myList = new Employee[1000];

for( int i=0; i<1000; i++ ) Employee [i] = new Employee();

    

}

                

public class sort(){

public class BubbleSort {

    static void bubbleSort(Employee[].getdept()) {

     int n = 100000;

       int temp = 0;  

     for(int i=0; i < n; i++){  

                 for(int j=1; j < (n-i); j++){  

                       if(emp.getdept[j-1] > emp[j]){  

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