Lab Assignment #5

Due Thursday, August 7 at the beginning of class

The assignment is to write a C++ program that counts the occurrences of each letter in a line of input. The program will prompt the user to type in a string of characters. After the user presses the return key, the program looks at each character, keeping count of how many of each letter were input. The program needs to deal only with the letters A through Z. Also, the program will not distinguish between uppercase letters and lowercase letters. This means that the letter 'A' and the letter 'a' are considered to be the same letter.
After the program calculates the counts, it will print a table listing each character, the number of times it occurred, and the relative frequency within the string. A final line will be printed after the table indicating the total number of letters that were in the string. Note that all spaces and punctuation are ignored, and therefore, are NOT considered to be letters. Here is an example of how the program prompts the user and displays the output:
Enter a string of characters, then press return:
The quick brown fox jumped over the lazy dogs.


Character     Occurrences    Frequency
---------------------------------------
    A              1           2.70%
    B              1           2.70%
    C              1           2.70%
    D              2           5.41%
    E              4          10.81%

    (fill in the rest of the table)

    Y              1           2.70%
    Z              1           2.70%

Total letters: 37
You must follow this format exactly. I will be using an automated script to input up to 1000 characters into your programs.

Details
How to submit your programs

Back to Outline