Question: Please help with this java assignment! Write three methods that will return a LinkedList, Stack, and Queue containing the following poem. Each word is an

Please help with this java assignment!

Write three methods that will return a LinkedList, Stack, and Queue containing the following poem. Each word is an element in the LinkedList, Stack, or Queue.

Hickory, dickory, dock. The mouse ran up the clock. The clock struck one and down he runs. Hickory, dickory, dock.

The header of each method is:

public static LinkedList createLLPoem() public static Stack createStackPoem() public static Queue createQueuePoem()

Then, write 3 methods that will return an int with the number of times that a word occurred in the linked list, queue, and stack. Before leaving each method, restore the structure that was passed, if it was destroyed in the process of reading it. The headers of these methods are:

public static int count(LinkedList theList, String word)

public static int count(Stack theStack, String word) public static int count(Queue theQueue, String word)

Within main:

Call the following 3 methods:

LinkedList theList = createLLPoem(); Stack theStack = createStackPoem(); Queue theQueue = createQueuePoem();

Print theList, theStack, and theQueue: System.out.println(Before..);

System.out.println(theList);

System.out.println(theStack);

System.out.println(theQueue);

Ask the user to enter any word in the poem, and store it in a String variable named aWord.

Call each of the following methods:

int countLL = count(theList, aWord);

int countStack = count(theStack, aWord);

int countQueue = count(theQueue, aWord);

Display a message of how many times aWord occurred in theList, theStack, & theQueue.

Repeat step b.) to re-print the list, stack, and queue, preceded by the title After.

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!