Write a java program implementing the Linked list.
It should be on an small office who has 5 employees. The program ask the user for ID, First name, Last name and what field the work in(eg: accounting, programmer, HR etc). Each employee (with all the information of that paticular employee) should be placed in one node in the program. The program should repeat and ask the user for all 5 employees information. Also when you display the Linked list it should be sorted by increasing order of the Employee ID. Employee Id should be the primary key . The program should also be able to delete an employee by their ID number. It should have an menu to ask the user for the following options:
Whole program is based on linked list and should be sorted.
import java.util.Scanner;
class ListNode{
int ID;
String fname;
String lname;
String fwork;
ListNode next;
public ListNode(int id,String name,String lname,String
work){
this.ID=id;
this.fname=name;
this.lname=lname;
this.fwork=work;
}
}
public class Employee {
ListNode head;
ListNode sorted;
void push(int id,String name,String lname,String
work){
ListNode newnode=new
ListNode(id,name,lname,work);
newnode.next=head;
head=newnode;
}
//..........utility function to sort the
list............
void insertionSort(ListNode headref){
sorted=null;
ListNode current=headref;
//pick node 1 by 1 and create a soted list ....
while(current!=null){
ListNode next=current.next;
sortedInsert(current);
current=next;
}
//assign the sorted list to orignal head node
head=sorted;
}
void sortedInsert(ListNode newnode){
if(sorted==null||sorted.ID>=newnode.ID){
newnode.next=sorted;
sorted=newnode;
}else{
ListNode current=sorted;
while (current.next != null
&& current.next.ID < newnode.ID)
{
current = current.next;
}
newnode.next = current.next;
current.next = newnode;
}
}
//..................utility ends.......................
void printlist(ListNode head)
{
ListNode temp=head;
if(temp==null){
System.out.println("List is empty");
}
while (temp != null)
{
System.out.println("Name:"+temp.fname +"
"+temp.lname+"ID:"+temp.ID+" Work:"+temp.fwork);
temp = temp.next;
}
}
void delete(int id){
//variable to hold node to be
deleted and previous node..
ListNode temp=head,prec=null;
//if node to be delted is first
node itself
if(temp!=null &&
temp.ID==id){
head=temp.next;
return;
}
//traverse through the list to find
node to be deleted
while(temp!=null &&
temp.ID!=id){
prec=temp;
temp=temp.next;
}
if(temp==null){
System.out.println("Employee is not
present in the list..");
return;
}
prec.next=temp.next;
}
public static void main(String[] args){
Employee list=new Employee();
int temp_NumOfEmployeesToEnter=5;
while(true){
System.out.println("1.To add an new employee\n"+
"2.To delete an
employee\n"+
"3.To search an
employee\n"+
"4.To display
list of employee\n");
Scanner sc=new Scanner(System.in);
int temp=sc.nextInt();
switch(temp){
case 1:
System.out.println("Enter
ID:");
int id=sc.nextInt();
System.out.println("Enter first
name:");
Scanner scc=new
Scanner(System.in);
String fname=scc.nextLine();
System.out.println("Enter last
name:");
String lname=scc.nextLine();
System.out.println("Enter
workProfile:(eg: accounting, programmer, HR etc)");
String work=scc.nextLine();
list.push(id, fname, lname,
work);
temp_NumOfEmployeesToEnter--;
if(temp_NumOfEmployeesToEnter<=0){
continue;
}else{
System.out.println("optional-Enter information for
"+temp_NumOfEmployeesToEnter+ " more employees");
}
break;
case 2:
System.out.println("Enter the
employee ID to be deleted");
id=sc.nextInt();
list.delete(id);
break;
case 3:
System.out.println("Enter the
employee ID to be searched");
int x=sc.nextInt();
ListNode current =list.head;
boolean temp_var=true;
//traverse list to find the employee...
while(current!=null){
if(current.ID==x){
System.out.println("Name:"+current.fname +"
"+current.lname+"ID:"+current.ID+" Work:"+current.fwork);
temp_var=false;
}
current=current.next;
}
if(temp_var){
System.out.println("Employee with
ID "+x+" does not exits");
}
break;
case 4:
list.insertionSort(list.head);
//sorting list and printing..
list.printlist(list.head);
break;
default:
System.out.println("Pleas enter
valid response");
}
}
}
}
//-----------------------------------Screen shot-------------------------------------//

Write a java program implementing the Linked list. It should be on an small office who...
Help in JAVA please Write a program that reads a list of students (first names only) from a file. It is possible for the names to be in unsorted order in the file but they have to be placed in sorted order within the linked list. The program should use a doubly linked list. Each node in the doubly linked list should have the student’s name, a pointer to the next student, and a pointer to the previous student. Here...
Linked List in Java The data node should be modeled somewhat like this: class node{ int node iNum; node next; } Write a program that creates a linked list and loads it with the numbers 0 to 9. Start with an empty list and then use a "for loop" to fill it. Create a linked list class, a node class, etc. Routines like makeNode and findTail should be methods in the linked list class. Create a showList function to display...
JAVA please Java problem that has to be in doubly linked list. It is game problem that I have to keep of the players' scores. this should have a Java blueprint class named player It should have two fields, the name and score and include the constructors, toString() method, and getters and setters. Scores must be kept in ascending order (smallest at the front ) in a doubly linked list. It has menu as well: Load original data Print the...
Create a linked list of at least 15 different values that are prompted for and entered while the program is running. Appending a node attaches that node to the end of the list while inserting a node places it in order maintaining a sorted list. Create a menu driven program where you have the options to appended, insert, display, and delete a node. Display the list after first appending data showing it in no specific order, delete all nodes and...
write a java program implementing stacks using arrays. (not with linked list)
Please use C++
CS3358 Insert and delete a node Programming Project 2: The linked list - Reference: chapter 18: Create an array of 15 student records that should not be sorted Create a liked list of 15 student record nodes. Each node is a node of one student record from the above unsorted array. The list of student records should be sorted by student ID. (Insert function without sort function to create a linked list.) (If you insert correctly, the...
you’ll write a program to illustrate how Linked list and structure are used in practice, we’ll develop a program that maintains a database of information about parts stored in a warehouse. The program is built around the database stored in linked list and structures, with each structure containing information - part number, name, and quantity – about one part. • The program tracks parts stored in a warehouse. • Contents of each structure: – Part number – Name – Quantity...
Part 1 (employee.py): Write a class name Employee that holds the following data about an employee in attributes:name, ID number, department and job title. Once you have written the class, write a program that creates three Employee objects to hold the following data: The program should store this data in the three objects, then display the data for each employee on the screen as a table like this (Use fstring or "format" function to format the output as a table,...
team, create a Java program that adds or removes entries from a linked list based on user input. You can use the index of the entry as the key to identify the record for addition or deletion. The program can be as simple as you like but must add an entry to the list based on the user input and also must delete the proper item in the list based on the index entered by the user Display your list...
Program is to be written In C++, The output should look like the
screen shot. It should allow the user to continue to ask the user
to enter all employee ID's until done and then prompt the user to
enter the hours and pay rate for each employee ID. Please help:(
Can you please run the program to make sure the output is just like
the screenshot please? It needs to have the output that is in the
screenshot provided,...