244: TEXT

Read & process a text file ONE CHARACTER at a time.
Count and report lines, words & characters.
Output file in ASCII and in hex.

0. Come to class as there may be corrections, changes and additions.   Stiff late submittal penalty.
1. Follow these directions to create a C# console program.  
2. Follow these directions to SUBMIT a folder called "TEXT" to your class account.
    The solution and project (and project folder) should also be called "TEXT".
3. Code for Readability! (guidelines)

readability ==> understandability ==> maintainability ==> $$$

Code should reflect your algorithm!
- heading: Name, Purpose, AlGORITHM (Examples)
- naming, indenting, vertical spacing, comments
- each function should have at least a one-line description

File opened must be called "data.txt" & should be in the project folder (with .csproj file).
Here is a link to a file to use. If you create your own file, use notepad or notepad++.

How do we START? Analyze the problem...

NOTE: There ARE easier ways to do this (getting the linecount from ReadLine() and the word count from Split()) - DON'T. I'm asking you to do things one character at a time to demonstrate your mastery of the skills required to do it this way. Also, you should be able to explain and defend EVERY line of code in your program.
Main() Init open fileS, declare variables, etc Loop until end of input file: Read ONE CHARACTER from text file (data.txt) and store into an array. Output each character to the the console screen as it is read and stored. How to read one character? (Read) How big should the array be? Is there a way to get file info (FileInfo) before reading? End Loop Call CountIt() Count the characters, words & lines in the file. create a void method, CountIt() for this task Parameters: pass in the character array pass in a reference to the character count pass in a reference to the word count pass in a reference to the line count Call Whitespace() determine if a character is a whitespace create a bool method, Whitespace(), that will tell whether a character is whitespace. Parameter: pass in a character return true or false Call WriteHex() Output to an output file (s_username.txt) (same folder as input) AND to the console EACH CHARACTER in HEX(2 digits) with a space between each hex character pair. create a void method, WriteHex() for this task Parameters: pass in the character array pass in the output file reference variable Output the counts of ALL THE THINGS to . the console . the output file (optional) Mop up End Program

HINTS: Characters include letters, symbols, digits and any white space characters. Words are separated by whitespace including ' ' and '\r'+'\n' and '\t' Lines are separated by '\r'+'\n' (0d 0a) To read a single char, c, see Read(), a method of the StreamReader class. To write a file look at the StreamWriter class. May need to CAST when manipulating the characters for various purposes. Will need a bool variable to keep track WHEN you are IN A WORD or NOT NOTE: Create the input file in Notepad++. (link to a data.txt file to use). If you create the file IN Visual Studio, you will get 3 extra characters (ef bb bf).

OUTPUT EXAMPLE: this is a simple file with some data 74 68 69 73 20 69 73 20 61 20 73 69 6D 70 6C 65 0D 0A 66 69 6C 65 0D 0A 20 20 20 77 69 74 68 0D 0A 0D 0A 73 6F 6D 65 20 64 61 74 61 44 characters, 8 words, 5 lines * NOTE: notepad++/view/summary reports 38 characters (doesn't count the 6 blanks)
An explanation of the hex output: 74 68 69 73 20 69 73 20 61 20 73 69 6D 70 6C 65 t h i s i s a s i m p l e 0D 0A 66 69 6C 65 f i l e 0D 0A 20 20 20 77 69 74 68 w i t h 0D 0A => this "pair" is the CR LF 0D 0A 73 6F 6D 65 20 64 61 74 61 s o m e d a t a