CS 312 Extended Exercise - Parameters, Strings, and Readability
NOTE: This is being posted for practice purposes only.
Not to be turned in.
If the help hours line is long we will not
address questions about this exercise.
Description: The purposes of this exericse are:
In this exercise you will write a program analyzes text typed in by the user for readability.
There are three sample files: sample1, sample2, and sample3.
Here are the inputs in a file you can download.
Note, some students have had trouble with the BlueJ IDE in the past when entering large amounts of text.
On this exercise you may only use the features discussed in chapters 1 through 4 of the textbook. (In particular you may not use arrays or methods from the String class not covered in chapter 3.) To get the most out of the exericse, do not use the split method from the String class and do not use a Scanner other than the one connected to System.in.
Introduction:
Implement a program that
determines the Flesch Readability Index for a
pieces of text. This method of calculating the readability of text was
devised by Rudolf Flesch, author of Why Johnny Can't Read
and The Art
of Readable Writing. When you check the spelling and grammar in a Word
document you can have the readability statistics displayed, including the Flesch
index.

The Flesch Readability Index is a number, generally between 0 and 100, that indicates how easy a piece of text should be to read. The lower the number, the harder the text is to read. A general breakdown of reading levels based on Flesch Index is:
Flesch Score
Approximate grade level
90 to 100
5th grade
80 to 90
6th grade
70 to 80
7th grade
60 to 70
8th to 9th grade
50 to 60
10 to 12th grade (high school)
30 to 50
13th to 16th grade (college level)
0 to 30
college graduate.
The index is calculated by a fixed set of rules for counting the number of sentences, words, and syllables in a piece of text. This can be automated via a computer program. Here is an example. Consider the following sentence:
It was an extraordinarily windy day, and thus the riders were faced with several arduous climbs up the mountain, with the wind trying to push them back down the road.
The Readability Index for that sentence is 60.8 using our modified algorithm. The following conveys almost the same idea,
It was a very windy day. The riders had many hard climbs up mountains. The wind kept pushing them back down the road.
but has a Readability Index of 103.4. This method of determining the readability of a piece of text does not do any sort of linguistic analysis so the results can be misleading, but the method usually produces a reasonable answer.
Examples:
Test sentence 1: This is a sentence. So is this!
Number
of sentences: 2
Number of words: 7
Number of syllables: 9
Flesch readability index: 94.5
Test sentence 2: The following index was invented by Flesch as a simple tool to estimate the legibility of a document without linguistic analysis.
Number
of sentences: 1
Number of words: 21
Number of syllables: 39
Flesch readability index: 28.4
Test sentence 3: Wette. It 'reven hem, or was revenrage. With hey kince kin himply to justron' wer", "stere what willi?
Number
of sentences: 3
Number of words: 18
Number of syllables: 27
Flesch readability index: 73.8
This example is merely to show the algorithm works regardless of if the input is standard English or not. You could even run the algorithm on source code, although the answer would not be very helpful or meaningful.
Hints:
By way of comparison, the suggested solution consists of 160 lines and 9 methods including main. Most of the 160 lines are comments, blank lines, or lines with a single }. The number of lines with actual code is about 75. Note, some methods are used to provide structure to the program even though they do not remove any redundancy.
When finished turn in your Flesch.java file via Canvas.
| Provided File | Responsibility |
| Provided by me | |
| Flesch.java (Provided shell) | You and me. (Okay, mostly you.) |