Question
Java Programming: Write a program called WordStatistics that: - Uses the fromFile method to direct StdIn to get its input from the a file. -
Java Programming:
Write a program called WordStatistics that:
- Uses the fromFile method to direct StdIn to get its input from the a file.
- Uses the readAllStrings method from StdIn to read and divide into words the file's text, placing that list of words into a String array;
- Declares an array of integers and fills it with the length of each word in the array of Strings
- Computes and prints the average length of the words
- Computes and prints the median length of the words
- Computing the average and computing the median should be in their own methods. The median should be computed with this algorithm:
If the length of the array is odd, the median is at the position (length divided by 2).
If the length is even, the median is the average of the two values at the positions (length divided by 2) and (length divided by 2 plus 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