Question: Write a program that reads a file of text and calculates the average number number of letters per word and words per sentence. The program

Write a program that reads a file of text and calculates the average number number of letters per word and words per sentence. The program does not have to have a GUI
 Write a program that reads a file of text and calculates
the average number number of letters per word and words per sentence.

GEEN163 Reading Level Program Part 185 points Some reading educators have claimed that you can judge the difficulty of a piece of text by counting the number of letters in a word and the number of words in a You are to write a program that reads a text file and reports the average number of letters in a word and the average number of words in a sentence. The java util Scanner next method will read a single English word from a text file. You can use this method to read individual words. For the purpose of this assignment, we will consider sentences to be a number of words that end with a period or an exclamation point. The last word of a sentence (when read with the next o method) will end with a period or an exclamation point(). The String method ends with will return a boolean value that is true if the word ends with a period. Your program should first ask the user the name ofthe input file. It should then use that name to create a java io File object and a java. Scanner object. The program needs to: count the number of letters count the number of words count the number of sentences (periods or exclamation points) The String length method can be used to get the number of letters in a word. Don't forget to subtract one from the length ifthe word ends in a period. The program should print the average number of letters per word and the average number of words per sentence. You can run your program using anytext file as input. Sample text files are available on Blackboard. Gettysburg address 4.411985018726591 letters per word 267 words per sentence Peter Rabbit 4.327004219409282 letters per word 18.58823529411765 words per sentence Frankenstein 4.53769581809933 letters per word 25.76211756617394 words per sentence Cat in the Hat 3.376543209876543 letters per word 8.481675392670157 words per sentence Page I of 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!