Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 4B (50 points + 5 bonus) in JAVA Implement a program that determines which word length occurs most frequently in a text file. That

Problem 4B (50 points + 5 bonus) in JAVA

Implement a program that determines which word length occurs most frequently in a text file. That is, your program should identify the word length such that there are more words of that length than of any other length. For instance, the most frequent word length in the example file is 2; the file includes four words of that length.

Input and output:

Your program should input the name of a text file, and print the word length that occurs most frequently in that file, as well as the number of words of that length. The file name is a string, the length of which is between 1 and 60. The file contains between 1 and 1,000 lines, each of which is between 1 and 60 characters long. The characters in the file include letters, spaces, and line breaks. The file does not include digits or punctuation marks, and it also does not include blank lines. A word in that file is any sequence of letters, surrounded by spaces or line breaks. We assume that the file has only one most frequent word length, that is, two different word lengths cannot tie for the greatest number of occurrences.

Example

image text in transcribed

Command Prompt C:Nhonework4b Enter nane of the input file: nessage.txt The nost frequent word length is 2 The nessage includes 4 words of that length C:N>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions