OBJECTIVES:
- Use arrays and string manipulation methods
OVERVIEW OF PROJECT:
Letter counting is an interesting application with real world use. Linguists count the letters used in literature as they study changes in language. Cryptographers count letters to help them break ciphers. This project will count the letters in the words and sentences entered in a text box.
PROJECT INSTRUCTIONS:
1. Create a new project.
2. Add a text box for the user to enter the text to evaluate. Set the Multiline property to True so the user’s text will wrap at the end of the line. Set the CharacterCasing to “Upper”.
3. Add a list box to use to display the counts of the letters that appear.
4. Add a command button or menu option to start the count. Inside the counting routine:
a) Clear listbox displays so that a new text will not include information from a previous count. Use listBox1.items.Clear().
b) Get the string from textbox and convert to char Array (char[]) using string ToCharArray() method.
c) Create 2 Arrays(char[] and int[]): one to store the character A-Z, another to store the count for each of the character.
d) Create a loop that will examine each individual character.
e) Use a loop to loop through A-Z array to compare. If the character is a letter, add to the count for that letter.
f) Evaluate the next character until all characters have been evaluated.
g) Display the number of times each character appeared.
Credits: Microsoft C# Projects for the Classroom (by Alfred C Thompson II)
0 comments:
Post a Comment