Question: Write a method called wordLengths that accepts a string for the name of a file as a parameter. Your method should open the given file,

Write a method called wordLengths that accepts a string for the name of a file as a parameter. Your method should open the given file, count the number of letters in every token in the file, and then output a result diagram of how many words contain each number of letters.For example consider a file containing the following text. Four score and seven years ago This is a different linesome Numbers 1 12 13 14 More Data Your method should produce the following output to the console: 1: ** 2: **** 3: ** 4. ****** 5. *** 6: 0 7: * 8: 0 9: * 10: 0 You can create your own sample text files, for testing purposes, but make sure they work correctly. You may assume that no token will have more than 20 characters
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
