This assignment requires using the Stack class to encode and decode a text file. For encoding, your program reads a text file (called text source file), uses the following rules to encode all letters and digits (nu changes for other characters), and then generates the coded output For decoding, your program reads a coded file (generated by the above encoding process), uses the same rules to decode all letters and digits (other characters remain the same), and finally generates the decoded file. The decoded file should be the same as the text source file.
You may read a file character by character using get(chal) function, and write a file character by character using pitticharl function. Encoding rules: each word in the file is printed in reverse order with each letter replaced by its successor and each digit replaced by its predecessor. Other characters embedded in a word are printed in their position but are not replaced. Words are recognized as groups of characters separated by blanks, commas, periods, the end of line, or other punctuations. The successor of 'z' is 'a', and the successor of 'Z' is 'A'. The predecessor of "a" is 'z', and the predecessor of 'A' is 'Z'. The predecessor of '0' is '9', and the successor of '9' is '0'. Your program should pnnnpt for the filename to be coded and then create a coded file with the source filename by appending the ".coded" suffix. For the decoded file, you can name it by appending the ".decoded" suffix to the coded filename. Stack class is used to reverse a word. You can process the characters one at a time, stacking them until the end of a word. You can feel free to use the stack class template from the lab exercises.
An example: Suppose the original text file is named "test.txt" and has one linens follows: CSCI-2380.02 Data Structure After encoding, a file named as "text.t.i.coded" is generated. The content of this file becomes:
JDTD-9721.19 bubE fsvudvsuT
After decoding, a file named as "text.txt.coded.decoded" is generated. This file should be the same as "test.txt":
CSCI-2380.02 Data Structure