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

a department form has one textbox for department name and one button to submit i

ID: 3837466 • Letter: A

Question

a department form has one textbox for department name and one button to submit input. It produces one table for output, which contains, Department name Manager name Number of employee’s currently assigned to that department

In the displayDepartmentsmethod, you will need three loops, with two of them nested. First loop cycles through the department linked list. Second loop cycles through the assignment linked list getting count of number of current employees for that department. Third loop cycles through the employee linked list locating the current manager for that department, if one exists.
Display one row at a time in the output table as you process through the above loop structure

how do i go about this?

dlist.sortDept();
// Search example through list for certain value
dNode nodeptr = dlist.getHead();
for (int i = 0; i < dlist.size(); i++) {
  
DefaultTableModel model=(DefaultTableModel) DepartmentsTable.getModel();{
Object[]newRowData={nodeptr.getDept(),

then somehow get the manager

aNode nodeptr = assignList.getHead();
for (int i = 0; i < assignList.size(); i++) {
DefaultTableModel model=(DefaultTableModel) AssignmentsTable.getModel();{
Object[]newRowData={nodeptr.getEmplyID(), nodeptr.getDept(),nodeptr.getLevel(),****


nodeptr = nodeptr.getNext();

Explanation / Answer

Hi,

Instead of looping throgh nested loops, we can create functions/methods to find the employee count and manager.

For getting the employee count, we can loop through each element of assignment linked list and compare the department name with the data passed.
If the data is equal/same , increase the count.
Algorithm:
1. Initialize employeecount as zero.
2. Loop through each element of linked list:
a) If departmentname is equal to the passed data then
increment the count.
3. Return count.

Simple Method in Java (similar approach can be used in other languages also):
/* Counts the no. of occurences of a node
(search_for) in a linked list (head)*/
int count(String search_for)
{
Node current = head;
int count = 0;
while (current != null)
{
if (current.departmentName == search_for)
count++;
current = current.next;
}
return count;
}
  
For getting the Manager Name, we can loop through the employee linked list and search the Manager for the department that is passed in the
testbox.
Algorithm:
1. Loop through each element of employee linked list:
a) If departmentname is equal to the passed data then read the manager name.

Please let us know in case of any issue. Thanks

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