Assignment 4 for CSCI 431

The gnat compiler for Ada has been installed on Burnsville. Here is a brief set of instructions for compiling a simple procedure or function (something that is not part of a package and does not use multiple tasks).

Programming Assignment

To complete this assignment, you will need to use conditionals (if, case), loops, CHARACTER manipulation, VAL and POS, and subprograms.

Program Description

Congratulations. You have been recruited by the CIA as senior programmer, and your first assignment is to decode messages that have been intercepted from the Albanian Secret Service (ASS). You know that ASS always encodes messages by first "rotating" all letters forward by some number N positions, then by rotating the upper case vowels one position forward and the lower case vowels one position backwards (see below).

(vowel rotations)
	change 'A' and 'a'  to 'E' and 'u' respectively
	change 'E' and 'e'  to 'I' and 'a' respectively
	change 'I' and 'i'  to 'O' and 'e' respectively
	change 'O' and 'o'  to 'U' and 'i' respectively
	change 'U' and 'u'  to 'A' and 'o' respectively
AE EI IO OU UA
au ea ie oi uo
For example, the message
     The Plane Leaves At 10:00PM.
may be encoded using a shift of 10 letter positions (so 'A' becomes 'K') followed by the vowel shift, which would give
     Dri Zvkxi Vikfic Kd 10:00ZW.
Note that a shift of a letter past 'Z' causes it to be shifted to the front, e.g., 'S' shifted by 10 gives 'C'. Also note that the encoding does not change the case of a letter (upper or lower).

One last piece of information: ASS messages always begin with the same word, "Agent" e.g.,

   Agent #12345:
             Please return to HQ ASAP.
Knowing that the first word of a message is always Agent allows you to determine the overall letter shift, N, for that message.

Write a program which decodes a message and writes the decoded message to the output.

Input

Your program should read the encoded message from the "standard" input. When you test your program, use UNIX I/O redirection...e.g.,

    $ myprog < message1.txt  > message1.out

Output

Your program should translate the message, character by character, and print it to the standard output.

Testing

To help you test your program, here is an Agent message and two encodings, encoding #1 and encoding #2,of that message; each encoding uses a different letter shift N.

More Information on Ada

Here is a little bit more information about the Text_IO package. Included in this description of Text_IO is the END_OF_FILE function. There are also several good Ada web sites, I've listed a few of them here.