| Lexington High School Mathematics | Math Dept. Front Page | Student Links | Family Links |
| Introduction to C++, Kevin Kelly | Kelly Front Page | C++ Course Guide | C++ Assignments | C++ Info |
Write a program that inputs several lines of text (such as a paragraph or a poem),
then counts the number of times that each letter of the alphabet appears in the text.
Treat upper- and lower-case versions as the same letter. Your output should look
like this:
7 A's
6 B's
3 C's
4 D's
...
2 Z's
Here's a hint: At some point in your program you will find it necessary to make a conversion from letters to numbers. Try this: if a character variable ch contains a capital letter, then the formula (ch - 'A') will produce a number in the range from 0 to 25. For example, if ch contains 'Z' then the value of (ch - 'A') will be 25.
Input for sample run: Use the 8th paragraph of
Martin Luther King's speech at the
March on Washington (this is the paragraph that begins
But there is something that I must say...).