Description
Objectives:
1. Read the contents of a data file (mytext.dat);
2. Process the frequency of characters (a-z) that appear in the data file
3. Print the frequency of characters in the file to the screen;
4. Be able to use an ifstream object;
In this assignment you will implement a program called “charword_freq.cpp”
to determine the number of words and the number of occurrences of each letter
in a block of text stored in a data file called “mytext.dat”. Define a word to be
any string of letters that is delimited at each end by either whitespace, a period, a
comma, or the beginning or end of a line. You can assume that the input consists
entirely of letters, whitespace, commas and periods. When outputting the
number of words and letters that occur in a line, be sure to count upper- and
lowercase versions of a letter as the same letter. Output the letters in
alphabetical order and list only those letters that do occur in the input data file.
Consider the following example:
Block of text in the data file:
hello world ALL is great. HELLO WORLD ALL IS GREAT. hellO worlD alL iS great.
Output of your program to the screen:
15 words
6 a
3 d
6 e
3 g
3 h
3 i
15 l
6 o
6 r
3 s
3 t
3 w
Your program should be modular, meaning that you should break it up into
smaller function(s). Your main program should be as small as possible and well
documented.
Handing in your program
Electronically submit the source file “charword_freq.cpp” in the Assignments area
of blackboard before the due date and time. Remember, no late assignments will be
accepted.