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

 import java.util.Scanner; public class PoD { public static void main( String

[] args ) { Scanner in = new Scanner( System.in ); LinkedList

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.hasNextInt())

{

int task = in.nextInt();

if (task == 0)

{

teamList.removeHead();

}

else if (task == 1)

{

teamList.removeTail();

}

}

System.out.println("FINAL TEAM:");

System.out.println(teamList);

in.close();

System.out.print("END OF OUTPUT");

}

}

----------------------------------------------------------------------------

import java.util.NoSuchElementException;

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;

}

//PLEASE START WORK HERE

//===============================================

/**

* @method removeHead()

* Remove node from head of the linked list

* @returns Object: head node of the linked list

*/

/**

* @method removeTail()

* Remove node from tail of the linked list

* @returns Object: tail node of the linked list

*/

//===============================================

//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;

}

}

Input Input is taken care of for you (in PoDjava). It reads in the number of team members, followed by each of the team members' names. Finally, it reads in one more name to check and see if that person has made the team. Processing Complete the contains method in the LinkedList class. Details of this are provided in the Java file at left. Output Output is taken care of for you (in PoDjava). If the person whose name is being checked against the team roster is on the list (i.e contained in the linked list), PoDjava outputs NAME is on the team. otherwise it outputs NAME did not make the team

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!