CPSC 231: Assignment 4 (Due Monday Nov. 4)

Weighting = 3%

Learning simple text manipulation

For this assignment you are to write a program that allows two rudimentary text manipulation operations to be performed on a line of text.  A line can contain a maximum of 80 characters (including spaces and the terminating period) which will consist of one or more words.  Each word on a line must be separated by a space.  The end of the line is marked by a period.  

Generic format of a line:

<word 1><sp><word 2><sp><word 3>...<word n>.

sp = the space separating each word

There are no limits on word size or the number of words that a line contains (subject to the 80 character limit) although operation two (alphabetizing) need only work when the user types in a line containing exactly two words.  

Text manipulation operations:

These operations will be implemented using Pascal procedures/functions and must somehow must make use of variable (as well as value) parameters.  However it is up to you determine exactly which modules take what type of parameter.

1. Analysis: Your program provides various statistics about a line: 

The results of all these statistics will exclude the period marking the end of the line.

2. Alphabetize:  Your program must be able to take as input a two word sentence and check to see if these words are in alphabetical order and if not it will put the words in the correct order.  It will then display the ordered words back to the user of the program in the same format that they were entered i.e., the words must be separated by a space and end with a period.  To simplify your assignment, your program need only compare words that are all the same case i.e., all capitals or all lower case.

An assignment submission that has implemented one of these operations and fulfilled all the other requirements will receive a maximum grade of B+.  Only assignments that have implemented both operations and fulfilled all other requirements will be eligible to receive a grade of A+.  

Other procedures/functions

1. Menu: The above procedures/functions will be called by a third procedure/function that displays a menu of operations in a fashion similar to the one shown below:

    Program Options:

    1) Analyze line

    2) Alphabetize line

    3) Quit program

The display procedure/function can either be called by yet another procedure/function or be called from the main program.

2. Initialize: Your program must have some sort of initialize procedure/function that initializes all array(s) to some default starting value (such as filling them all with spaces).  

Other requirements

1. Good coding style and documentation:  They will play a role in determining your final grade for this assignment.  Your grade can be reduced by a full step e.g., "A" to "A-" for poor style.

2. Including a structure diagram:  For this assignment, you also you need to submit a structure diagram that shows the different modules that comprise your program and how those modules relate to each other.  Hand drawn diagrams are okay as long as it is neat and legible.  An example(s) of these diagrams will be covered in lecture.  Failure to submit a correct structure diagram will result in the loss of a full letter step e.g., "B-" to "C+".

Learning Objectives

Understanding and using one-dimensional arrays in Pascal.  Learning how to break large programming problems down (modularize) with Pascal procedures/functions. 

Submitting the assignment

There are two major steps required in the submission of this assignment:

1. Step for the electronic submission 

Use the submit system to electronically submit the source code for your assignment i.e., the file with the dot-p ".p" suffix.  In addition you must  also submit a text file called "README" for your TA.  This file will provide step-by-step instructions for running your program, as well what version of the assignment you have completed and any special cases or conditions that you may have implemented in addition to the requirements of the basic assignment.  It must be clear and complete enough so that your TA will  know how to mark your assignment (don't expect your marker to have to decipher cryptic instructions). 

2. Step for the paper submission

Print out the source code for your assignment (print the source code directly rather than running a script and then printing the script) and put the source code stapled with your structure diagram into the  appropriate drop box located on the second floor of Math Sciences.