Question: import java.util.Scanner; public class PoD { public static void main( String [] args ) { Scanner in = new Scanner( System.in ); LinkedList teamList =

![[] args ) { Scanner in = new Scanner( System.in ); LinkedList](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f301ff6139d_79166f301ff1289a.jpg)
import java.util.Scanner;
public class PoD
{
public static void main( String [] args )
{
Scanner in = new Scanner( System.in );
LinkedList teamList = new LinkedList();
final int TEAM_SIZE = Integer.valueOf(in.nextLine());
for (int i=0; i { String newTeamMember = in.nextLine(); teamList.append(newTeamMember); } while (in.hasNext()) { String removeMember = in.nextLine(); teamList.remove(removeMember); } System.out.println("FINAL TEAM:"); System.out.println(teamList); in.close(); System.out.print("END OF OUTPUT"); } } =========================================================================================== import java.util.NoSuchElementException; /** * A listnked list is a sequence of nodes with efficient element * insertion and removal. This class contains a subset of the methods * of the standard java.util.LinkedList class. * * You will finish off the contains method. */ public class LinkedList { //attributes private Node head; private Node tail; //Node class Node { public Object data; public Node previous; public Node next; } /** * Constructs an empty linked list/ */ public LinkedList() { head = null; tail = null; } /** * @method removeHead() * @param Object : object to be removed * @returns void * * Removes node from the linked list */ public void remove(Object data) { //PLEASE START WORK HERE //=============================================== //=============================================== //PLEASE END WORK HERE } /** * Appends a new node to the end of the linked list. */ public void append(Object element) { if (head == null) //Empty linked list { Node firstNode = new Node(); firstNode.data = element; firstNode.previous = null; firstNode.next = null; head = firstNode; tail = firstNode; } else //At least one node already exists. { Node newNode = new Node(); newNode.data = element; newNode.previous = tail; newNode.next = null; tail.next = newNode; tail = newNode; } } public String toString() { Node position = head; String output = ""; while (position != null) { output += position.data + " "; position = position.next; } return output; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
