Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data structures and algorithms java please give me easy code Q3: Given the following class Employee: public class Employee private int ID; private String name;

Data structures and algorithms
java
please give me easy code image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Q3: Given the following class Employee: public class Employee private int ID; private String name; privte char gender; public Employee(int myID, String myName, char myGender) ID = myID; name = myName; gender = myGender; ID(ID = my name smyNancander) public void setID(int myID(ID = myID;) public void setName(String myName){name = myName:} public void setGeneder(char myGender){gender = myGender:) public int getIDO{return ID;) public String getName({return name:} public char getGender({return gender:) 1. Write a class Department that keeps a record of the employees within the department in an array. It also has a name, maximum number of employees (maxEmp) and current number of employees (numEmp). This class should provide: a. A constructor to initialize the name of the department and the maximum number of employees and create an empty employees array. b. An addEmployee method that creates an employee and adds it to the employees array. (void addEmployee (int, String, char)) C. A search method that takes the id of the employee and return its index in the array employees. d. A remove method that removes an employee with a specific id from employees array and return his/her record if found, otherwise return null. (Note: shifting maybe required) e. A percentGender method that takes the gender and print the percentage of the employees of that gender to the total employees f. A print method that prints the department name and all employees in a tabular format as shown in the sample output. 2. Write a test program Department Test. In the main do the following: a Create a department object with name "Financial Department and 5 as maximum number of employees. b. Display a menu of choice as in the sample output. The program should stop and exit when user enters 6. c. Check the sample output and follow it in your program. d. If the user choses 6 print the time complexity for each method: addEmployee, search, remove, and percentGender. Sample output Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Enter an employee id or -1 to stop: 123 Enter employee name: Ahmad Enter employee gender: Wrong Gender!! Enter employee gender: Enter an employee id or -1 to stop: 132 Enter employee name: Sara Enter employee gender: Enter an employee id or -1 to stop: 400 Enter employee name: May Enter employee gender: Enter an employee id or -1 to stop: 134 Enter employee name: asim Enter employee gender: Enter an employee id or -1 to stop: 500 Enter employee name: Naser Enter employee gender: Enter an employee id or -1 to stop: 900 Sorry, the department reached its capacity of employees. Enter an employee id or -1 to stop: Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Employees of department: Human Resource id name gender 123 Ahmad 132 Sara 400 May 134 Jasim 500 Naser Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Enter the id of the employee you want to remove 123 Employee Ahmad with id 123 has been removed. Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Enter an employee id or -1 to stop: 300 Enter employee name: Reem Enter employee gender: Enter an employee id or -1 to stop: Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Enter the id of the employee you want to remove 123 Sorry the employee with id 123 does not exist and cannot be removed. Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Employees of department: Human Resource id name gender 132 Sara 400 May 134 Jasim 500 Naser 300 Reem Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Enter the employee ID: 500 The employee is Naser Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Enter the gender: The percentage of F employees is 60% Choose one of the following: 1) Add employee 2) Search for an employee 3) Remove an employee 4) Find percentage of employees of specific gender 5) Print current department info 6) Exit Thank you for using this program, the time complexity of: addEmployee is 0(777) search is 0 (77?) remove is 0 (???) percentGender is (7)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

3. Would you say that effective teamwork saved their lives?

Answered: 1 week ago