Question
In this problem, we will implement a simple dictionary of common words in the English language, represented as an array of words paired with their
In this problem, we will implement a simple dictionary of common words in the English language, represented as an array of words paired with their lengths. You will need to implement each of the below methods in the Dictionary class. In this problem, the first line of input represents the method to call. It will be one of the following: MIN, MAX, RANGE, AVERAGE, MODE. The second line will represent an integer n, which denotes the number of words in the list. The following n lines will each be a word. The words will not necessarily be sorted. Your output should be a single line representing the results of the method.
(a) Implement the minWordLength() method, which should return the length of the smallest word in the list.
(b) Implement a method called maxWordLength(), which should return the length of the largest word in the list.
(c) Implement a method called wordLengthRange(), which should return the range of lengths in the word list.
(d) Implement a method called averageWordLength(), which should return the average word length in the word list. The method should return the average, accurate to exactly two decimal places (i.e. if the average length is 5, return 5.00).
(e) Implement a method called mostCommonWordLength(), which should return the most common length of the words in the list. If there is a tie, you should return -1. You may assume that the length of a word is at most 100 and at least 1.
Step 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