Hands On C++: Project 5


The Projects

Your instructor will assign you one of the problems below. To solve your problem, write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Following the pattern in the lab exercise, first, design using OCD; then code your design in C++ using stepwise translation; finally, test your program thoroughly.

Project #5.1: As written, our Piglatin() function fails to correctly translate words such as yes (esyay) and yellow (ellowyay) in which the first vowel 'y' is actually being used as a consonant. It also fails to correct 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 Piglatin() so that it will correctly translate words like yes, yellow, quiet, quack, and squire without losing the ability to correctly translate words like style, rhythm, luck, and blue.

Project #5.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 #5.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 #5.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. (Hint: You may find the % operator to be useful.)

Turn In

Turn the following things:

  1. This grade sheet.
  2. Your OCD.
  3. Your source program.
  4. The output from an execution of your program.


Lab Home Page | Lab Exercise
© 2003 by Prentice Hall. All rights reserved.
Report all errors to Jeremy D. Frens.