Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. (12 points) Show that the equation has exactly one solution:

Answered: 1 week ago

Question

Describe how to train managers to coach employees. page 404

Answered: 1 week ago

Question

Discuss the steps in the development planning process. page 381

Answered: 1 week ago