Pre-Test

CS 23

Feb. 5, 1997

Solve the following problem, using the most appropriate data organization to model the problem data. Your program will be called from another program, so it is not possible to query a user for the name of an input file nor the name of an output file. Treat this problem as if it were an exam problem; you may neither give nor receive help on it. All questions regarding the problem are to be resolved during today's class. Here is the problem:

A.16. Write a program that will read English prose and list in alphabetical order all the words that occur in the prose, along with a count of the number of times each word occurs.

The heart of this program will be a function that reads in a word. If you agree to treat any character other than the letters A through Z as a delimiter, you can define a word to be any string of up to eight characters that is surrounded by delimiters. If a string between delimiters is more than eight characters, read the entire string, but truncate it to eight characters when you record it.

You can assume that the text will contain at most 100 distinct words.

By 5:00 pm on Thursday, e-mail me your solution or drop it in my mailbox in the Department. Just after 5:00 pm, I will post a solution on the class home page. On Friday, you are to hand-in a written self-evaluation of your solution.



Thomas P. Kelliher
Thu Feb 6 15:16:36 EST 1997
Tom Kelliher