Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Project 2 Word Count
- Due Friday November 21, 2014
- Overview
- You will create a program that prints out statistics for a given file, similar to the Unix program wc.
- Requirements
- Your program must:
- ● Ask the user for the name of a file to process
- ● Print out the number of characters (including whitespace), words and lines in the file
- ● Print the average and median word length
- ● Print the 10 longest words, along with the length of each word.
- For the purposes of this assignment, a word is any sequence of nonwhitespace characters, so "hello",
- "world!","--xkz,"and "&&^.2"all count, but "DanRoberts"does not.
- For the longest words, no words should appear more than once. If there are not enough words in the file,
- your program should print what words it can in order and then stop. If several words have the same length,
- the order in which they are printed does not matter.
- Make sure to follow the style guide and write plenty of comments!
- Extra Credit
- To earn additional points (2 each) your program may:
- ● Print the 10 most frequent words, along with the number of times they appear (same rules as longest
- words above)
- ● Be impossible to crash
- Testing
- We have provided two files, veggies.txt and hamlet.txt, along with expected output for each. Your program
- should match these exactly, except for the extra credit. Make sure to write your own tests as well!Grading Rubric
- Functionality Point value
- Read from the requested file 2
- Character, word and line counts 6
- Average word length 2
- Median word length 2
- 10 longest words 4
- Peer review 2
- Style 2
- Total 20
- Sample Output Blue text is user input, black text is program output.
- veggies.txt hamlet.txt
- Filetoprocess:veggies.txt
- Characters:91
- Words:12
- Lines:7
- Averagewordlength:6.666666666666667
- Medianwordlength:6.0
- Longestwords:
- 15-brussels-sprout
- 8-cucumber
- 7-carrots
- 6-potato
- 5-onion
- 4-leek
- Mostfrequentwords:
- 4-potato
- 3-onion
- 2-carrots
- 1-leek
- 1-brussels-sprout
- 1-cucumber
- Filetoprocess:hamlet.txt
- Characters:180716
- Words:31656
- Lines:6771
- Averagewordlength:4.432998483699772
- Medianwordlength:4.0
- Longestwords:
- 37-tragical-comical-historical-pastoral,
- 22-character:--'Naked!'--
- 20-historical-pastoral,
- 20-good-night.--Indeed,
- 20-columbines:--there's
- 20-difference.--There's
- 20-tragical-historical,
- 18-Horatio:--Welcome,
- 18-madness,--thoughts
- 18-conceive:--friend,
- Mostfrequentwords:
- 989-the
- 696-and
- 625-of
- 604-to
- 509-I
- 448-a
- 444-my
- 384-in
- 363-you
- 358-Ham.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement