ITEC 320: Programming Assignment 2

Due by 11:59:59 of Friday 2/16/2018

Submit Command: submit itec320-01 pal_finder.adb

Last modified:

  1. 2018 Feb 08 02:38:08 PM: Set due date, changed sample run, added assignment checker, removed DRAFT

You can see an example of this program at assignment checker (which uses gnoga to integrate the GUI, web server, and problem solution). On-campus or VPN session required.
Write a program that reads a series of strings and prints one of the following five messages that indicates whether each string is a palindrome or can be converted into a palindrome. Here is a sample run: If the input file, mydata.txt, consists of these lines:
  madam i'm adam!
This is a random sentence!

Then a sample run is as follows:
>pal_finder < mydata.txt
String: "eve"
Status: Palindrome as entered

String: "!eve!"
Status: Palindrome as entered

String: "Eve"
Status: Palindrome when converted to upper case

String: "eve!!"
Status: Palindrome when non-letters are removed
Characters removed: 2

String: "Eve!!!"
Status: Palindrome when non-letters are removed and converted to upper case
Characters removed: 3

String: "  madam i'm adam!"
Status: Palindrome when non-letters are removed
Characters removed: 6

String: "This is a random sentence!"
Status: Not a palindrome

String: ""
Status: Palindrome as entered

String: "!!!$$$"
Status: Palindrome when non-letters are removed
Characters removed: 6
Input: Input comes from standard input, and each line of the input will contain one string to be checked. Processing will continue until end of file is reached. Your program should not have any prompts.

Output format: Your output should follow the example above. As shown, the output will consist of the string and its status, each with the suitable label. If character removal is needed to make a palindrome, display the number of non-letters that are removed. Print a blank line after the output for each string.

Other points

  1. Do not use type Unbounded_String.
  2. You can assume that each input line is 72 or fewer characters. A string can be empty.
  3. Note that when removing punctuation and spaces, the spaces that you remove must include those on the beginning and end of the string.
  4. You must use, and make good use of, the following:
    1. a procedure with 1 or more parameters, including an out parameter
    2. a function with 1 or more parameters
    3. an array (remember that a String is an array!)
    4. an enumerated type
  5. Make sure that you test your program on rucs.
  6. You may want to consider using ada.text_io.get_line(s, len) .
  7. Make sure that you do NOT use any GLOBAL VARIABLES in your program! All communication with procedures and functions must be via parameters and return values!

Style: In coming up with your Ada solution to the following problem, please follow my style guide. In particular, please note the use of consistent indentation, named constants, and descriptive constant and variable names. Please remember that the first thing in any program file should be a comment that gives a brief overview of what the file contains (and should do). Also remember to keep your lines less than 80 characters long. Not only does this mean that printouts won't run off the side of the page, but it also makes your programs look neater on an 80 column wide xterm window (a popular size). If you are unsure of an element of programming style, please ask, as I would be more than happy to show you what I want.

Submission: Use the submit command to turn your program in for grading. You may submit as many times as you like, but only the last submission is kept. In particular, be aware that since only the last submission is kept, if the last one is late, then your assignment is late and will thus receive a late penalty. Also remember that you must be on rucs2 for submit to work. To submit your work for grading use the submit command at the top of the assignment.