CSC160 (UG20) 01
PA 5.1: Word stats
Skip To Content
Dashboard
  • Login
  • Dashboard
  • Calendar
  • Inbox
  • Help
Close
  • My Dashboard
  • CSC160 (UG20) 01
  • Assignments
  • PA 5.1: Word stats
SP 2021 (UNDG)
  • Home
  • Assignments
  • Modules
  • TC/WC Appt Scheduler
  • Collaborations
  • WSJ Context
  • EvaluationKIT Course
  • EvaluationKIT
  • Barnes & Noble Bookstore
  • Badges
  • Stukent

PA 5.1: Word stats

  • Due Mar 30, 2021 by 11:59pm
  • Points 10
  • Submitting a file upload
  • File Types cpp
  • Available after Mar 16, 2021 at 2pm

When completing this programming assignment, you may work with up to one other person. No groups of more than two are permitted.

Write a program that reads in text from the user until they enter the word DONEZO, then reports several stats about their text. Specifically, it should report:

  • the number of total words entered
  • the number of distinct words (case insensitive)
  • the number of characters (the length of all input words summed together)
  • the distribution of distinct words and their corresponding counts represented as a "bar graph" of characters (see the example)

You should use parallel (multiple) vectors or arrays to keep track of distinct words and their frequencies. For distinct words, use the `tolower()` function described in zyBook chapter 3.14 Character operations. You'll need to apply this to each character in an input word.  For showing the word distributions as bar graphs, you can use a loop to add enough spaces after a word (based on it's length) before the bar chart starts, or, if you'd like, you may use `setw`, as described in zyBook chapter 9.2 (and detailed in Table 9.2.2), to set the width of the word to something reasonable (e.g., 15 or 20).

Here's a run of a program that meets these criteria (your output doesn't have to look exactly the same as long as it has the same information and your formatting is good). User input is shown in bold orange.

$ ./word-stats
==== WORD STATS ====
Enter your text and enter END (all caps) when you're finished:
Mary had a little LAMB
little lamb
little lamb
Mary had a little lamb whose fleece was white as snow DONEZO


Stats:
words: 20
distinct words: 10
characters: 81

Distribution:
mary XX
had XX
a XX
little XXXX
lamb XXXX
whose X
fleece X
was X
white X
as X
snow X

Copy the following header and specifications checklist and paste it at the top of your source code. As you complete the specifications, fill in the [ ] next to that specification in the check list (e.g., like this: [x]). I will not grade submissions with missing specifications; please do not submit if you cannot check all of them off.  This specs checklist is essentially a way for you to self grade before you submit your program.

// Name: 
// Date: 
// Partner: 
//
// Specifications checklist for PA 5.1 Word Stats
//
// General specs:
// [ ] the header includes your name and anyone you worked with
// [ ] the header includes this specifications checklist with all completed 
//     specifications checked off: [x]
// [ ] the code is indented properly (inside of every block, code is indented 
//     one more tab)
// [ ] each chunk of code that "hangs together" (works toward a higher level goal):
//     [ ] includes a brief, useful comment above it
//     [ ] is separated from the next chunk by a blank line
// [ ] there are no really long lines of code or comments (if you have long
// lines, split them across multiple shorter lines)
// [ ] identifiers are well named
// [ ] the program compiles 
// [ ] the program runs without crashing or hanging
// [ ] all output and prompts look clean (correct spelling, capitalization, 
//     nothing squished)
// [ ] all prompts make it clear what data the user is expected to enter and in 
//     what format and work as expected
//
// Specific specs: 
// [ ] the program prompts the user for their text (can be multiple lines of text)
// [ ] all words entered by the user are read in until the sentinel DONEZO is read in
// [ ] the DONEZO sentinel is not counted in any of the stats
// [ ] the program uses parallel (multiple) arrays or vectors to store words and their counts
// [ ] words are stored and reported at the end in all lower case
// [ ] these stats are displayed at the end and are accurate:
// [ ] the total number of words entered
// [ ] the number of distinct words (case insensitive)
// [ ] the number of characters (the length of all input words summed together,
// spaces not included)
// [ ] the distribution of distinct words and their corresponding counts are
// represented as a bar graph
// [ ] the left side of the bar graphs are aligned across words

If you are working with a partner, both of you must submit individually.

1617163199 03/30/2021 11:59pm
Additional Comments:
Rating max score to > pts

Rubric

 
 
 
 
 
 
 
     
Can't change a rubric once you've started using it.  
Find a Rubric
Find Rubric
Title
You've already rated students with this rubric. Any major changes could affect their assessment results.
Title
Criteria Ratings Pts
Edit criterion description Delete criterion row
This criterion is linked to a Learning Outcome Description of criterion
threshold: 5 pts
Edit rating Delete rating
5 to >0 pts
Full Marks
blank
Edit rating Delete rating
0 to >0 pts
No Marks
blank_2
This area will be used by the assessor to leave comments related to this criterion.
pts
  / 5 pts
--
Additional Comments
Total Points: 5 out of 5