Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Example Output: 1. Display Words 2. Display Reversed Words 3. Quit 1 a Alice Alice and and bank ... 1. Display Words 2. Display Reversed
Example Output:
1. Display Words
2. Display Reversed Words
3. Quit
1
a
Alice
Alice
and
and
bank
...
1. Display Words
2. Display Reversed Words
3. Quit
2
without
what
was
was
very
use
...
1. Display Words
2. Display Reversed Words
3. Quit
3
Quitting...
*Please include all the requirement methods and no more added methods in this lab.
List of Words Create a program that reads in a file words.txt" and stores them in a LinkedList. Allow the user to choose to display the list forward or backward, or to quit. Create the following functions: 1. readFile - construct the LinkedList and a ListIterator, read in the file and add each word to the LinkedList. Call movelter to move the iterator to the correct position to add each word, so the list is always in sorted order. Return the list. 2. moveIter - pass in the ListIterator and the new word. Move the iterator backward or forward from its current position to find the correct location to place the word so the list always stays in sorted order (note: use String's compare ToIgnoreCase method so it sorts the words regardless of capitalization). 3. printForward pass in the list, create a ListIterator that starts at the beginning of the list, iterate through the list to display the contents. 4. printReversed - pass in the list, create a ListIterator that starts at the end of the list, iterate through the list to display the contents in reverse order. 5. menu - display the menu and get the user's choice. Return the input. Menu Repeat the menu until the user quits. 1. Display Words 2. Display Reversed Words 3. Quit Notes: 1. Read in the file when the program starts (happens only once). 2. Use an iterator to move through the list to add the words, one at a time, in sorted order. DO NOT add all the items and then just sort the list. The point of the assignment is to practice using iterators. 3. The iterator should be moving back and forth through the list. You should not reset the iterator to the front every time a new word is added from the file. 4. Check the user's input for the menu. You do not need to error check the strings. Starting Out - 1. Start with a stripped-down version of the readFile function. Start with reading in the file and adding the words directly to the end of the LinkedList. 2. Create the printForward and printReversed functions. 3. Create the menu function and the main. 4. Create the moveIter function. Compare the new word to the word at the iterator's position, then move the iterator forwards or backwards to the correct position. 5. Go back and update the readFile function to call movelter to add the new word at that position when moveIter returnsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started