Lecture notes for the Introduction to multidisciplinary Computer Science II by James Tam Return to the course web page

CPSC 219: Assignment 2

New Concepts to be applied for the assignment

Part I: Enhanced encryption program.

This version of the program still employs the same encryption algorithms that you used in the previous assignment: the Caesar Cipher variant and the bitwise negation. But you are to expand upon that simple program so that it can now read the text to be encrypted from a text file specified by the user. The program will allow the user to select the method of encryption and the encrypted text will be written to a second text file. Finally you will implement a second program that reverses the process: it reads from the encrypted version of the text and writes an decrypted version of the text to a third file. You would have already gotten credit for the parts of the assignment that were the main focus of the previous assignment, e.g., the encryption algorithms, so those parts of the assignment won't be graded in this subsequent assignment.

Features to be implemented (you will also be graded on other criteria such as coding style and providing program documentation as listed in the marking guide):

  1. Prompts for and reads in the name of the text file to be encrypted.
  1. Opens and reads the text from the input file.
  1. Opens a writes the encrypted text to the file called "encrypted.txt".
  1. A variant debug mode is implemented that records the decimal ASCII codes of the encrypted text to a third text file.
  1. The program checks for errors that might have occurred while opening the files (e.g., the input file isn't at the location specified, the program cannot open the output file because the permissions in the file system don't allow it etc.)
  1. A second program is written that decrypts the encrypted text. It will do this by reading the encrypted text from the file "encrypted.txt" and write a decrypted version to a file chosen by the user. The user's choice determines which encryption algorithm which be reversed, you are not expected to write a program that can automatically determine the algorithm used.

 

Part II: Simple text analysis, making system calls

You are to write a program that will read the text from the file "data.txt" into an array. Each line of text from the file will be read into a row of the array. The program will then analyze the text in the file and generate the following information: a character count, a word count and a sentence count. The full version of the program will then use a system call to dictionary check each word in the document via the program "dict". Because the output of the program is likely to scroll through many screens full of information, your program should be written so that it can work using UNIX redirection (i.e., it should not ask the user for any input while it's running). Finally a debug mode will be implemented that shows the individual words from the input file that are looked up in the UNIX dictionary.

Features to be implemented (you will also be graded on other criteria such as coding style and providing program documentation as listed in the marking guide):

  1. Reads the text from the input file into an array. (Although it's not required for the assignment you should write a test function to make sure that you completed this step properly). Each line of text from the input file will be read successively into the rows of the array.
  1. The program checks for problems reading from the input file (e.g., the input file isn't at the location specified, the program cannot open the output file because the permissions in the file system don't allow it etc.).
  1. A text analysis is performed.
 
  1. Character count: it should be clearly documented whether your program literally counts all characters in the file (alpha, numeric, formatting etc.) or just the alphabetic ones. My program ignores the formatting 'enter' character but otherwise counts everything else.
 
  1. Word count. Words are separated by spaces or terminated by punctuation.
 
  1. Sentence count: Sentences will end in some form of punctuation.
  1. The program will dictionary check each word in the input file. Again since the results will likely scroll through many screens so your program should be able to handle a redirection of the output. While your program can use output statements as usual it should not have any statements that require user input.
  1. A debug mode is implemented that shows the exact phrase being passed to the system call. For example if the input file consisted of the following phrase: "Blue skys to forever." then the following output should be produced while the program is in debug mode:

  dict Blue
dict skys
dict to
dict forever

 

In this case the user won't be able to turn the debug mode on and off at a prompt from the program because the output is supposed to be redirected so you should simply use a variable to determine if your program is in debug mode or not. You (and your marker) can toggle debug mode (and the display of the debugging messages on/off) by editing the program to change the value of the variable. The program documentation should make it clear how the debug mode is supposed to work and how to engage/disengage it.

 

Submitting your work:

  1. Assignments (source code/'dot-c' file) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].
  3. Before you submit your assignment to help make sure that you haven't missed anything here is a [checklist] of items to be used in marking.