4. This question involves the process of taking a list of words, called wordList, and producing a formatted string of a specified length. The list wordList contains at least two words, consisting of letters only. When the formatted string is constructed, spaces are placed in the gaps between words so that as many spaces as possible are evenly distributed to each gap. The equal number of spaces inserted into each gap is referred to as the basic gap width. Any leftover spaces are inserted one at a time into the gaps from left to right until there are no more leftover spaces. The following three examples illustrate these concepts. In each example, the list of words is to be placed into a formatted string of length 20. Example 1: wordList: ["AP", "COMP", "SCI", "ROCKS"] Total number of letters in words: 14 Number of gaps between words: 3 Basic gap width: 2 Leftover spaces: 0 Formatted string: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |A|P| | |C|O|M|P| | |S|C|1| | |R|O|C|K|S| I Example 2: wordList: ["GREEN", "EGGS", "AND", "HAM"] Total number of letters in words: 15 Number of gaps between words: 3 Basic gap width: 1 Leftover spaces: 2 The leftover spaces are inserted one at a time between the words from left to right until there are no more leftover spaces. In this example, the first two gaps get an extra space. Formatted string: 0 1 2 3 4 G R E E N 5 6 7 E 8 9 10 11 12 13 G|G|S| | 14 15 16 17 18 19 A N D H A M Example 3: wordList: ["BEACH", "BALL"] Total number of letters in words: 9 Number of gaps between words: 1 Basic gap width: 11 Leftover spaces: 0 Formatted string: 012 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |B|E|A|C| H |A|L|I You will implement three static methods in a class named StringFormatter that is not shown.
4. This question involves the process of taking a list of words, called wordList, and producing a formatted string of a specified length. The list wordList contains at least two words, consisting of letters only. When the formatted string is constructed, spaces are placed in the gaps between words so that as many spaces as possible are evenly distributed to each gap. The equal number of spaces inserted into each gap is referred to as the basic gap width. Any leftover spaces are inserted one at a time into the gaps from left to right until there are no more leftover spaces. The following three examples illustrate these concepts. In each example, the list of words is to be placed into a formatted string of length 20. Example 1: wordList: ["AP", "COMP", "SCI", "ROCKS"] Total number of letters in words: 14 Number of gaps between words: 3 Basic gap width: 2 Leftover spaces: 0 Formatted string: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |A|P| | |C|O|M|P| | |S|C|1| | |R|O|C|K|S| I Example 2: wordList: ["GREEN", "EGGS", "AND", "HAM"] Total number of letters in words: 15 Number of gaps between words: 3 Basic gap width: 1 Leftover spaces: 2 The leftover spaces are inserted one at a time between the words from left to right until there are no more leftover spaces. In this example, the first two gaps get an extra space. Formatted string: 0 1 2 3 4 G R E E N 5 6 7 E 8 9 10 11 12 13 G|G|S| | 14 15 16 17 18 19 A N D H A M Example 3: wordList: ["BEACH", "BALL"] Total number of letters in words: 9 Number of gaps between words: 1 Basic gap width: 11 Leftover spaces: 0 Formatted string: 012 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |B|E|A|C| H |A|L|I You will implement three static methods in a class named StringFormatter that is not shown.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY