Professional Documents
Culture Documents
1
Sort Program
Monday 04/25/2011
Due in Handin Folder anytime Wednesday 5/4/2011
Hardcopy due: Anytime Thursday 5/5/2011
Name: Grade:
1
Date:
1
Permission to post? yes no
I may post your assignment on the class disk, but only if you check yes.
Status:
sortv1 (60): Complete, no issues Unresolved Issues2 Not Attempted
sortv2 (10): Complete, no issues Unresolved Issues2 Not Attempted
sortv3 (10): Complete, no issues Unresolved Issues2 Not Attempted
sortv4 (10): Complete, no issues Unresolved Issues2 Not Attempted
sortv5 (10): Complete, no issues Unresolved Issues2 Not Attempted
*sortv6 (10): Complete, no issues Unresolved Issues2 Not Attempted
2
Description of Unresolved Issues:
1
The purpose of this assignment is to read in a list of words and display reports
showing the words and their lengths in alphabetic order and in order by length. You
are also to display the length of the shortest word, the length of the longest word,
the average word length and a table showing how many words there are of each
length.
sortv1: (60pts) Build the word and length arrays from “v:\words.txt”
Write a program which reads the contents of words.txt, one word at a time into an
array of strings. As you do this, store the length of each word in a parallel array of
ints. When you have finished reading in all the words, call the displayReport()
function to display the words and their lengths.
2
sortv2: (20pts) Determine the minimum, maximum, and average lengths
Complete min(), max(), sum(), and average() functions and use them to determine
the shortest, longest, and average word length.
Call the displayReaport() function after each sort. Be sure to give the report an
appropriate title.
Functions to complete for part 3: We will write the sort() function in class.
Here are sample reports:
Words and Word Lengths Sorted Alphabetically by Word
WORD LENGTH
average 7
computer 8
engineering 11
freshman 8
grade 5
junior 6
Pentium 7
point 5
science 8
school 6
senior 6
software 8
sophomore 9
3
Words and Word Lengths Sorted by Length
WORD LENGTH
grade 5
point 5
junior 6
senior 6
school 6
average 7
Pentium 7
computer 8
science 8
software 8
freshman 8
sophomore 9
engineering 11
Modify the program so that the user enters the name of the word file and the
program opens it from the some folder the program is in.
4
*sortv6: (10pts extra) Process files containing multiples of some words
Modify the program so that it can process a file with multiple occurrences of some
of the words. The program should keep track of how many times each word occurs
but only store it once in the array(Hint: use a linear search to look for the word, if
you fin it, increment its count, if you don’t, store it in the array with a count of 1).
The program will also have to strip off punctuation and convert to all upper or all
lower case. Modify the sort() and the displayReport() to handle the array of word
counts. Add statistics for the word counts like you have for the word lengths.
You can use the quote.txt file as the input for this part.