Project 6


The Projects

Project #6.1:
(a) Check to see how your englishToPigLatin() function translates strings such as "grrrrr" that contain no vowels. If necessary, modify your function so that it leaves such strings unchanged.

(b) The englishToPigLatin() function is designed to handle words made up of only lowercase letters. Modify it so that it will also handle words that contain or consist entirely of uppercase letters.

(c) The englishToPigLatin() function fails to correctly translate words such as quiet (ietquay) and quack (ackquay), in which the first vowel is a 'u' following a 'q'. Redesign the algorithm used by englishToPigLatin() and modify the function's code appropriately so that it will correctly translate words like quiet, quack, and squire but still translate "Qatar" as "atarQay."

Project #6.2: A character string is said to be a palindrome if it reads the same when the order of its characters is reversed. For example, the following are all palindromes:
madam
smada bob adams
able was I ere I saw elba
Write a function that, given a character string, returns true if that string is a palindrome, and returns false otherwise.

Project #6.3: A (very) simple encryption method is to reverse the order of the characters in a word, so that if the characters in the message
OEMOR OEMOR EROFEREHW TRA UOHT
are reversed word-by-word, then the decoded message reads:
ROMEO ROMEO WHEREFORE ART THOU
Write a function that, given a character string, returns the reverse of that character string.

Project #6.4: Internet mailers and news-readers often contain a "rot13" function that can be used to "encrypt" words by rotating their characters 13 positions (i.e., A becomes N, B becomes O, C becomes P, ... Z becomes M). This is convenient, because the same function can be used to both "encrypt" and "decrypt" a word:
rot13("ROMEO") == "EBZRB"
and
rot13("EBZRB") == "ROMEO"
Write a rot13() function that, given a string, returns a string whose characters are those of the first string rotated 13 positions. It should use only the properties of the string class that we have studied. Also, it should perform this rotation by applying appropriate arithmetic operations to the individual characters; it should not simply use a case statement with 52 cases, each of which replaces one letter with some other letter.


Back to the Lab Exercise

Back to This Lab's Home Page


Report errors to Larry Nyhoff (nyhl@cs.calvin.edu)