Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. Project 2 ­ Word Count
  2. Due Friday November 21, 2014
  3. Overview
  4. You will create a program that prints out statistics for a given file, similar to the Unix program wc.
  5. Requirements
  6. Your program must:
  7. ● Ask the user for the name of a file to process
  8. ● Print out the number of characters (including whitespace), words and lines in the file
  9. ● Print the average and median word length
  10. ● Print the 10 longest words, along with the length of each word.
  11. For the purposes of this assignment, a word is any sequence of non­whitespace characters, so "hello",
  12. "world!","--xkz,"and "&&^.2"all count, but "DanRoberts"does not.
  13. For the longest words, no words should appear more than once. If there are not enough words in the file,
  14. your program should print what words it can in order and then stop. If several words have the same length,
  15. the order in which they are printed does not matter.
  16. Make sure to follow the style guide and write plenty of comments!
  17. Extra Credit
  18. To earn additional points (2 each) your program may:
  19. ● Print the 10 most frequent words, along with the number of times they appear (same rules as longest
  20. words above)
  21. ● Be impossible to crash
  22. Testing
  23. We have provided two files, veggies.txt and hamlet.txt, along with expected output for each. Your program
  24. should match these exactly, except for the extra credit. Make sure to write your own tests as well!Grading Rubric
  25. Functionality Point value
  26. Read from the requested file 2
  27. Character, word and line counts 6
  28. Average word length 2
  29. Median word length 2
  30. 10 longest words 4
  31. Peer review 2
  32. Style 2
  33. Total 20
  34. Sample Output Blue text is user input, black text is program output.
  35. veggies.txt hamlet.txt
  36. Filetoprocess:veggies.txt
  37. Characters:91
  38. Words:12
  39. Lines:7
  40. Averagewordlength:6.666666666666667
  41. Medianwordlength:6.0
  42. Longestwords:
  43. 15-brussels-sprout
  44. 8-cucumber
  45. 7-carrots
  46. 6-potato
  47. 5-onion
  48. 4-leek
  49. Mostfrequentwords:
  50. 4-potato
  51. 3-onion
  52. 2-carrots
  53. 1-leek
  54. 1-brussels-sprout
  55. 1-cucumber
  56. Filetoprocess:hamlet.txt
  57. Characters:180716
  58. Words:31656
  59. Lines:6771
  60. Averagewordlength:4.432998483699772
  61. Medianwordlength:4.0
  62. Longestwords:
  63. 37-tragical-comical-historical-pastoral,
  64. 22-character:--'Naked!'--
  65. 20-historical-pastoral,
  66. 20-good-night.--Indeed,
  67. 20-columbines:--there's
  68. 20-difference.--There's
  69. 20-tragical-historical,
  70. 18-Horatio:--Welcome,
  71. 18-madness,--thoughts
  72. 18-conceive:--friend,
  73. Mostfrequentwords:
  74. 989-the
  75. 696-and
  76. 625-of
  77. 604-to
  78. 509-I
  79. 448-a
  80. 444-my
  81. 384-in
  82. 363-you
  83. 358-Ham.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement