In: Computer Science
How do I write a COBOL program that translates a word entered into pig Latin?
Q1.How to write a COBOL program that translates a word entered into to Pig Latin."
Solution:
Words beginning with consonants are converted into pig latin
as
follows: toy is oytay, zoo is oozay and so on.
Words beginning with vowels are converted as follows: aunt is
auntay,
act is actay.
1. You can use UNSTRING to parse text into words, breaking it
at spaces, commas, periods, colons, etc.
2. You can then use UNSTRING on each word, specifying all
consonants
as the delimiters
...DELIMITED BY "B" OR "C" OR "D" OR "F" OR etc
INTO PRE-CON DELIMITER IN DEL1,
POST-CON
3. I don't have the spec handy, but I THINK PRE-CON will be left
alone
if
the word began with one of the delimiters.
If the PRE-CON is unchanged, then the word began with a
consonant,
which is in DEL1, otherwise it began with a vowel.
Eventually, for consonant-beginners you can use STRING to gather
up
POST-CON, DEL1, and "AY" into a single string.
you COULD use the tools Glenn and Arnold suggested for
disassembly,
then just use STRING to organize them.