Define and implement a class named WordList similar to the MyArray class in the lectures the past 2 weeks. Your WordList class should have the following data members and methods: data members: String[] list : array of n words (assume 1 ≤ n ≤ 20) int n : number of words in list methods: 1. WordList() - constructor for WordList class 2. read() – read a sentence consisting of English words using a .nextLine() statement, break each word off the sentence, and save the words in array with one word in each array element keeping the relative order of the words unchanged. 3. print() – use the array contents to print the word list 4. sort() – sort the words in the array in alphabetical order using the insertion sort method. For example, if "To be or not to be, that is the question." is entered for the initial sentence: 1. read() will build array {"To", "be", "or", "not", "to", "be", "that", "is", "the", "question"} 2. print() will use the array contents to print: To be or not to be that is the question 3. sort() will sort the words in the array to {"be", "be", "is", "not", "or", "question", "that", "the", "To", "to"} You may assume input sentences consist of only alphabet letters, commas, periods and blanks. 1. You must use For loops. 2. You may not use the Array class or any of its methods. 3. If appropriate for this algorithm, you should validate any input from the user to make sure the data input is an appropriate value to work in your program’s logic. You don’t have to worry about validating that it is the correct data type. For now, assume the user is only giving you the correct data type and just worry about validating the value given is usable in your program.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

Define and implement a class named WordList similar to the MyArray class in the lectures the
past 2 weeks. Your WordList class should have the following data members and methods:
data members:
String[] list : array of n words (assume 1 ≤ n ≤ 20)
int n : number of words in list
methods:
1. WordList() - constructor for WordList class
2. read() – read a sentence consisting of English words using a .nextLine() statement,
break each word off the sentence, and save the words in array with one word in each
array element keeping the relative order of the words unchanged.
3. print() – use the array contents to print the word list
4. sort() – sort the words in the array in alphabetical order using the insertion sort
method.
For example, if "To be or not to be, that is the question." is entered for the initial sentence:
1. read() will build array {"To", "be", "or", "not", "to", "be", "that", "is", "the",
"question"}
2. print() will use the array contents to print:
To be or not to be that is the question
3. sort() will sort the words in the array to {"be", "be", "is", "not", "or", "question",
"that", "the", "To", "to"}
You may assume input sentences consist of only alphabet letters, commas, periods and blanks.

1. You must use For loops.
2. You may not use the Array class or any of its methods.
3. If appropriate for this algorithm, you should validate any input from the user to make
sure the data input is an appropriate value to work in your program’s logic. You don’t
have to worry about validating that it is the correct data type. For now, assume the user
is only giving you the correct data type and just worry about validating the value given is
usable in your program.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT