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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education